使用其他相机进行立体声校准 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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...