我創建了一個在Simulink S函數(這是C++代碼)中實現的視覺算法。除了顏色和深度圖像的對齊之外,我完成了所有想要的任務。合併rgb和深度圖像從一個kinect
我的問題是我怎樣才能使2圖像相互對應。換句話說,我如何使用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;
}
如可以在輸出中可以看出我的程序,當我應用唯一的白色面具的深度圖像四直升機機身不包括1顏色。原因是這兩個圖像之間存在匹配錯誤。
我知道我需要我的相機的校準參數,我從最後一個使用此設置的人那裏得到了這些參數。在Matlab中進行了校準,結果如下。
我花了配發的時間閱讀有關攝像機標定和三維重建以下OpenCV的頁面(可以不包括因爲堆棧交換拉特的鏈接)
,但我不能對於我來說,我想知道如何實現向每個彩色像素添加正確深度值的目標。
我試過使用reprojectImageTo3D()但我找不出Q矩陣。 我也嘗試從該頁面分配其他功能,但我似乎無法讓我的輸入正確。
如果你正在寫自己的Simulink模塊,你可以嘗試使用MATLAB功能塊做在MATLAB。 – Dima