2

我需要使用 libfreenect2 registration::apply 与颜色/深度图像重建 PointCloud。问题是我将颜色和深度图像预先保存为 PNG 文件。颜色和深度图像都是使用 libfreenect2::Frame 获得的,并转换为 OpenCV Mat 用于 imwrite。

Mat(rgb->height, rgb->width, CV_8UC4, rgb->data).copyTo(bgrImage);
Mat(depth->height, depth->width, CV_32FC1, depth->data).copyTo(depthImage);

我尝试了以下方法来获取我的颜色框架并且它可以工作。问题是当我尝试对深度图像做同样的事情时,问题就出现了。

Mat color_CV8UC3 = cv::imread(colorFilename);
cvtColor(color_CV8UC3, color_CV8UC4, CV_BGR2BGRA);  //Convert to BGRX
libfreenect2::Frame rgb(color_CV8UC4.cols, color_CV8UC4.rows, 4, color_CV8UC4.data);

Mat depthImg = cv::imread(depthFilename);            
depthImg.convertTo(depthFrame, CV_32FC1, 1.0/255.0);  //Convert to 32FC1        
libfreenect2::Frame depth(depthFrame.cols, depthFrame.rows, 4, depthFrame.data); 

我通过为 rgb 和深度重新转换 libfreenect2::Frame 来测试 cv::Mat 到 libfreenect2::Frame 的转换,虽然我为 rgb 获得了相同的图像,但深度图像并非如此。

Mat(rgb.height, rgb.width, CV_8UC4, rgb.data).copyTo(rgb_image);
Mat(depth.height, depth.width, CV_32FC1, depth.data ).copyTo(depth_image);
imshow("Depth", depth_image);       
imshow("Color", rgb_image);

深度图像 - 加载并转换为 32FC1 深度图像 - 加载并转换为 32FC1

深度图像 - 转换为帧并重新转换回来后 深度图像 - 转换为帧并重新转换回来后

感谢您提供的任何帮助,请提供任何反馈,因为这是我第一次在这里发布问题。

4

0 回答 0