首页 文章

深度点 Cloud ,迭代器错了吗?

提问于
浏览
0

Depth

Point cloud
嗨我正在将深度图像转换为点 Cloud ,它似乎停在图像宽度的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);
        }

    }

1 回答

  • 0

    我会说它必须是

    depth.at<float>(x,y)
    

相关问题