微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用其他相机进行立体声校准 opencv; C ++

如何解决使用其他相机进行立体声校准 opencv; C ++

我有两个不同的相机。一个是1280 x 720分辨率,另一个是5472 x 3648。

您可以在此处下载示例图像:https://drive.google.com/drive/folders/1KH24pnLHORG5tCN6bH-wKzPPWLc_fFVs?usp=sharing

如您所见,5472x3648图像的FOV小于1280x720图像。

我想进行立体声校准,但结果完全错误

cv::Mat cameraMatrix[2],distCoeffs[2];
cv::Mat R,T,E,F;
cv::Size imageSize = cv::Size(5472,3648);
double rms;

// reading intrinsic parameters
cv::FileStorage fs(camera1InputFilename,FileStorage::READ);
cv::FileStorage fs_2(camera2InputFilename,FileStorage::READ);

// Camera_0,5472x3648 resolution
fs["camera_matrix"] >> cameraMatrix[0];
fs["distortion_coefficients"] >> distCoeffs[0];
// Camera_1,1280x720 resolution
fs_2["camera_matrix"] >> cameraMatrix[1];
fs_2["distortion_coefficients"] >> distCoeffs[1];

rms = cv::stereoCalibrate(objectPoints,imagePoints[0],imagePoints[1],cameraMatrix[0],distCoeffs[0],cameraMatrix[1],distCoeffs[1],imageSize,R,F,cv::CALIB_FIX_INTRINSIC | cv::CALIB_FIX_FOCAL_LENGTH | cv::CALIB_ZERO_TANGENT_disT,cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS,100,1e-5));

所以我在互联网上搜索解决方案,发现应该重新计算内在参数,以使两台摄像机的分辨率相同。

cv::Mat cameraMatrix[2],3648);
double rms;
double width1 = 5472,height1 = 3648;
double width2 = 1280,height2 = 720;

// reading intrinsic parameters
cv::FileStorage fs(camera1InputFilename,1280x720 resolution
fs_2["camera_matrix"] >> cameraMatrix[1];
fs_2["distortion_coefficients"] >> distCoeffs[1];

double sx = width1 / width2;
double sy = height1 / height2;
cameraMatrix[1].at<double>(0,0) *= sx;
cameraMatrix[1].at<double>(0,2) *= sx;
cameraMatrix[1].at<double>(1,1) *= sy;
cameraMatrix[1].at<double>(1,2) *= sy;

rms = cv::stereoCalibrate(objectPoints,1e-5));

但均方根结果仍然很大。 我该怎么改变?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。