我正在尝试获取空间中多个点的3D坐标,但是从undistortPoints()
和triangulatePoints()
中得到了奇怪的结果。
由于两个相机具有不同的分辨率,我分别对它们进行了校准,并获得了0.34
和0.43
的RMS误差,然后使用stereoCalibrate()
获得更多矩阵,得到了0.708
的RMS值,然后使用stereoRectify()
获得其余矩阵。有了这些,我开始处理收集到的坐标,但是结果很奇怪。
例如,输入是:(935, 262)
,而undistortPoints()
输出的一个点是(1228.709125, 342.79841)
,另一个点是(934, 176)
和(1227.9016, 292.4686)
。这很奇怪,因为这些点都非常靠近帧的中心,变形最小。我没有预料到它们会移动300像素。
当传递给traingulatePoints()
时,结果变得更加奇怪-我用尺子测量了现实生活中三个点之间的距离,并计算了每张照片上像素之间的距离。因为这次点在一个相当平坦的平面上,这两个长度(像素和实际)匹配,即| AB | / | BC |在两种情况下都大约是4/9。然而,triangulatePoints()
给我带来了超出预期的结果,其中| AB | / | BC |为3/2或4/2。
这是我的代码:
double pointsBok[2] = { bokList[j].toFloat()+xBok/2, bokList[j+1].toFloat()+yBok/2 };
cv::Mat imgPointsBokProper = cv::Mat(1,1, CV_64FC2, pointsBok);
double pointsTyl[2] = { tylList[j].toFloat()+xTyl/2, tylList[j+1].toFloat()+yTyl/2 };
//cv::Mat imgPointsTyl = cv::Mat(2,1, CV_64FC1, pointsTyl);
cv::Mat imgPointsTylProper = cv::Mat(1,1, CV_64FC2, pointsTyl);
cv::undistortPoints(imgPointsBokProper, imgPointsBokProper,
intrinsicOne, distCoeffsOne, R1, P1);
cv::undistortPoints(imgPointsTylProper, imgPointsTylProper,
intrinsicTwo, distCoeffsTwo, R2, P2);
cv::triangulatePoints(P1, P2, imgWutBok, imgWutTyl, point4D);
double wResult = point4D.at<double>(3,0);
double realX = point4D.at<double>(0,0)/wResult;
double realY = point4D.at<double>(1,0)/wResult;
double realZ = point4D.at<double>(2,0)/wResult;
点之间的角度有点好但通常不是很好:
`7,16816 168,389 4,44275` vs `5,85232 170,422 3,72561` (degrees)
`8,44743 166,835 4,71715` vs `12,4064 158,132 9,46158`
`9,34182 165,388 5,26994` vs `19,0785 150,883 10,0389`
我曾尝试在整个帧上使用undistort()
,但结果仍然很奇怪。点B和C之间的距离应该始终保持不变,但这就是我得到的结果:
7502,42
4876,46
3230,13
2740,67
2239,95
逐帧分析。
角度:
stereoRectify
对图像进行校正,以便对应点具有相同的高度,否则视差图将不准确。 - Azad