gpt4 book ai didi

c++ - 合并来自kinect的rgb和深度图像

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:16:21 25 4
gpt4 key购买 nike

我正在创建一个在 Simulink S 函数(C++ 代码)中实现的视觉算法。除了颜色和深度图像的对齐,我完成了所有想要的事情。

我的问题是如何使两张图片相互对应。换句话说,我如何使用 opencv 制作 3d 图像。

我知道我的问题可能有点含糊,所以我会附上我的代码来解释这个问题

#include "opencv2/opencv.hpp"

using namespace cv;

int main(int argc, char** argv)
{
// reading in the color and depth image
Mat color = imread("whitepaint_col.PNG", CV_LOAD_IMAGE_UNCHANGED);
Mat depth = imread("whitepaint_dep.PNG", CV_LOAD_IMAGE_UNCHANGED);

// show bouth the color and depth image
namedWindow("color", CV_WINDOW_AUTOSIZE);
imshow("color", color);
namedWindow("depth", CV_WINDOW_AUTOSIZE);
imshow("depth", depth);

// thershold the color image for the color white
Mat onlywhite;
inRange(color, Scalar(200, 200, 200), Scalar(255, 255, 255), onlywhite);

//display the mask
namedWindow("onlywhite", CV_WINDOW_AUTOSIZE);
imshow("onlywhite", onlywhite);

// apply the mask to the depth image
Mat nocalibration;
depth.copyTo(nocalibration, onlywhite);

//show the result
namedWindow("nocalibration", CV_WINDOW_AUTOSIZE);
imshow("nocalibration", nocalibration);


waitKey(0);
destroyAllWindows;
return 0;
}

output of the program :

enter image description here

当我将 onlywhite mask 应用于深度图像时,从我的程序输出中可以看出,四轴飞行器机身不包含一种颜色。原因是 2 个图像之间存在未匹配。

我知道我需要我的相机的校准参数,我从最后一个使用此设置的人那里得到了这些参数。是否在 Matlab 中进行了校准,结果如下。

Matlab calibration esults :

/image/JwFi5.png

我花了很多时间阅读以下关于相机校准和 3D 重建的 opencv 页面(由于堆栈交换 lvl,无法包含链接)

但我终究无法弄清楚如何才能实现为每个彩色像素添加正确深度值的目标。

我尝试使用 reprojectImageTo3D() 但我无法计算出 Q 矩阵。我还尝试从该页面分配其他功能,但我似乎无法正确输入。

最佳答案

据我所知,Matlab 对 Kinect(尤其是 v1)有很好的支持。您可以使用名为 alignColorToDepth 的函数,如下所示:

[alignedFlippedImage,flippedDepthImage] = alignColorToDepth(depthImage,colorImage,depthDevice)

返回值为alignedFlippedImage(RGB 配准图像)和flippedDepthImage(配准深度图像)。这两张图片已对齐,可供您处理。

您可以在 this MathWorks documentation page 找到更多信息.

希望这是你需要的:)

关于c++ - 合并来自kinect的rgb和深度图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33167580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com