gpt4 book ai didi

opencv - 为什么cv::stereoRectify返回大小为(0,0)的ROI

转载 作者:行者123 更新时间:2023-12-02 17:38:13 33 4
gpt4 key购买 nike

我正在学习opencv并测试立体相机。在我的代码中,stereoRectify函数有时会返回其大小为(0,0)的ROI。
我无法弄清楚这个问题。

Mat cameraMatrix[2], distCoeffs[2];
cameraMatrix[0] = initCameraMatrix2D(objectPoints, imagePoints_l,
imageSize, 0);
cameraMatrix[1] = initCameraMatrix2D(objectPoints, imagePoints_r,
imageSize, 0);

Mat R, T, E, F;
double rms = stereoCalibrate(objectPoints, imagePoints_l, imagePoints_r,
cameraMatrix[0], distCoeffs[0],
cameraMatrix[1], distCoeffs[1],
imageSize, R, T, E, F,
CALIB_FIX_ASPECT_RATIO +
CALIB_ZERO_TANGENT_DIST +
CALIB_USE_INTRINSIC_GUESS +
CALIB_SAME_FOCAL_LENGTH +
CALIB_RATIONAL_MODEL +
CALIB_FIX_K3 + CALIB_FIX_K4 + CALIB_FIX_K5,
TermCriteria(TermCriteria::COUNT + TermCriteria::EPS, 100, 1e-5));

Mat R1, R2, P1, P2, Q;
Rect validRoi[2];

stereoRectify(cameraMatrix[0], distCoeffs[0],
cameraMatrix[1], distCoeffs[1],
imageSize, R, T, R1, R2, P1, P2, Q,
CALIB_ZERO_DISPARITY, 0.5, imageSize, &validRoi[0], &validRoi[1]);

cout << validRoi[0] << validRoi[1] << endl;

在终端输出:
[0 x 0 from (0, 0)][215 x 184 from (77, 19)]

要么:
[0 x 0 from (0, 0)][0 x 0 from (0, 0)]

我还输出了相机矩阵和失真矩阵:
[204.3355426705726, 0, 193.3280616575545;
0, 189.8976931576431, 123.307676870377;
0, 0, 1]
[-0.5404320611827982, 0.3292134879059271, 0, 0, 0, 0, 0,
0.1371856537119246, 0, 0, 0, 0, 0, 0]
[204.3355426705726, 0, 183.756931129648;
0, 189.8976931576431, 131.4500619272754;
0, 0, 1]
[-0.524923482702874, 0.3121043629068334, 0, 0, 0, 0, 0,
0.1269780773557047, 0, 0, 0, 0, 0, 0]

最佳答案

截至目前(2018年3月31日,opencv 3.4.1),许多用户报告立体声矫正返回无效结果:

https://github.com/opencv/opencv/issues/11131

关于opencv - 为什么cv::stereoRectify返回大小为(0,0)的ROI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47882362/

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