【问题标题】:Depth to point cloud, iterator wrong?深度到点云,迭代器错了吗?
【发布时间】:2016-10-13 08:03:23
【问题描述】:

嗨,我正在将深度图像转换为点云,它似乎停在图像宽度的 1/3 处。也许我通过坐标的迭代中的某些东西是错误的?

    float* p = (float*)depth.data; // one option to iterate through
    int index1 = 0; // just for counting the points
    for (int y = 0; y < depthImageSize.height; ++y)
    {
        for (int x = 0; x < depthImageSize.width; ++x)
        {
            pcl::PointXYZRGBA pt;
            //float depthValue = static_cast<float>(*p);
            float depthValue = depth.at<float>(y,x);
            //cout << p.pos() << endl;
            //cout << x << ", " << y << ": " << depthValue << endl;
            //++p;
            index1++;

            if (depthValue == -1000.f || depthValue == 0.0f || boost::math::isnan(depthValue))
            {
            }
            else
            {

                pt.x = (static_cast<float>(x) - centerX) * scaleFactorX * depthValue;
                pt.y = (centerY - static_cast<float>(y)) * scaleFactorY * depthValue;
                pt.z = depthValue;

                //bgr has to be resized
                cv::resize(bgr,bgr,depth.size());
                cv::Vec3b colorValue = bgr.at<cv::Vec3b>(y, x);
                RGBValue color;
                color.Red = colorValue[2];
                color.Green = colorValue[1];
                color.Blue = colorValue[0];
                pt.rgba = color.long_value;


            }
            result->points.push_back(pt);
        }

    }

【问题讨论】:

    标签: c++ point-cloud-library mat


    【解决方案1】:

    我会说它必须是

    depth.at<float>(x,y)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-21
      • 2012-11-23
      • 1970-01-01
      • 2020-03-14
      • 1970-01-01
      • 1970-01-01
      • 2020-04-11
      相关资源
      最近更新 更多