kinect v2深度颜色映射

时间:2016-10-17 15:33:25

标签: c++ kinect point-cloud-library camera-calibration color-depth

我正在努力克服kinect v2的深度颜色。我正在使用录制的,而不是实时数据,因此我无法使用CoordinateMapper。 我正在采用这种方法:http://nicolas.burrus.name/index.php/Research/KinectCalibration 不幸的是我无法在任何地方找到kinect v2的失真参数,所以我正在跳过将原始深度值转换为米。任何人都可以提供吗?我的点云看起来很不错!但是我的色彩映射根本不起作用。为了调试,我尝试创建bgr图像的变换图像(color_img_transformed),但它看起来非常错误: enter image description here enter image description here

for (int y = 0; y < depth.rows; ++y)
    {
        for (int x = 0; x < depth.cols; ++x)
        {
            float depthValue = (float) depth.at<float>(y,x);
            pcl::PointXYZRGBA pt;
            if (depthValue == -1000.f || depthValue == 0.0f || boost::math::isnan(depthValue))
            {

            }
            else
            {
                //depthValue *= 1000; // i think values are already in mm
                pt.x = (static_cast<float>(x + tmp_x) - centerX) * scaleFactorX * depthValue;
                pt.y = (centerY - static_cast<float>(y + tmp_y)) * scaleFactorY * depthValue;
                pt.z = depthValue;


                // new try to map - https://www.codefull.org/2016/03/align-depth-and-color-frames-depth-and-rgb-registration/
                // Apply RGB intrinsics
                Eigen::Vector4f tmp = extrinsics_ * Eigen::Vector4f(pt.x,pt.y,pt.z,1);


                float x_ = (tmp[0] * fx_rgb / tmp[2]) + cx_rgb;
                float y_ = (tmp[1] * fy_rgb / tmp[2]) + cy_rgb;


                // "x" and "y" are indices into the RGB frame, but they may contain
                // invalid values (which correspond to the parts of the scene not visible
                // to the RGB camera.
                // Do we have a valid index?
                if (x_ > bgr.size().width || y_ > bgr.size().height || x_ < 1 || y < 1)
                    continue;

                // Need some kind of interpolation. I just did it the lazy way
                int round_x = (int) floor(x_);
                int round_y = (int) floor(y_); 


                cv::Vec3b colorValue = bgr.at<cv::Vec3b>(round_y, round_x);
                RGBValue color;
                color.Red = colorValue[2];
                color.Green = colorValue[1];
                color.Blue = colorValue[0];
                pt.rgba = color.long_value;
                color_img_transformed.at<cv::Vec3b>(round_y, round_x)[0] = 255;//colorValue[0];
                color_img_transformed.at<cv::Vec3b>(round_y, round_x)[1] = 0;//colorValue[1];
                color_img_transformed.at<cv::Vec3b>(round_y, round_x)[2] = 0;
             }
        }
   }

我不太确定我是否使用了正确的外在/内在函数。有人可以对他们发表评论吗?

0 个答案:

没有答案