本文介绍了对不同摄像机(RGB和红外)进行校准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在校准两个摄像机时遇到问题:第一个是rgb,第二个是红外.它们具有不同的分辨率(我调整了大小并裁剪了较大的图像),焦距等...

I have problems with calibrating two cameras: first is rgb and second is infrared. They have different resolution (I resized and croped bigger image), focal length, etc...

示例:

RGB 1920x1080

RGB 1920x1080

红外512x424

Infrared 512x424

如何相互校准?我应该在stereoCalibrate中使用哪些参数.默认样本stereo_calib.cpp会产生很大的错误.像这样的东西: https://www.dropbox.com/s/x57rrzp1ejm3cac/%D0%A1%D0%BA%D1% 80%D0%B8%D0%BD%D1%88%D0%BE%D1%82%202014-04-05%2012.54.17.png

How to calibrate them to each other? What parameters should I use in stereoCalibrate.Default sample stereo_calib.cpp produce very big error.Something like this: https://www.dropbox.com/s/x57rrzp1ejm3cac/%D0%A1%D0%BA%D1%80%D0%B8%D0%BD%D1%88%D0%BE%D1%82%202014-04-05%2012.54.17.png

完成,RMS错误= 4.1026

done with RMS error=4.1026

平均投影错误err = 10.2601

average reprojection err = 10.2601

更新

我使用Calibration.cpp示例分别为每个摄像机生成了校准参数.对于RGB相机,我首先调整大小并裁剪图像以使其分辨率与IR相机(512x424)相匹配,然后进行校准.对于RGB摄像机,我得到camera.yml,对于红外摄像机,我得到camera_ir.yml.然后,我尝试使用修改后的stereo_calib.cpp示例进行立体声校准.在调用stereoticCalibrate之前,我从文件中读取了相机的camera_matrix和畸变系数参数,并将这些矩阵放入stereoCalibrate中.

I generated calibration parameters for each cameras independently using calibration.cpp example. For RGB camera I first resize and crop image to resolution matches IR camera (512x424), then calibrate. For RGB camera I get camera.yml, for IR camera I get camera_ir.yml.Then I try make stereo calibration using modified stereo_calib.cpp example. Before call stereoCalibrate I read camera_matrix and distortion_coefficients params for cameras from files, and put these matrices into stereoCalibrate.

FileStorage rgbCamSettings("camera.yml", CV_STORAGE_READ);
Mat rgbCameraMatrix;
Mat rgbDistCoeffs;
rgbCamSettings["camera_matrix"] >> rgbCameraMatrix;
rgbCamSettings["distortion_coefficients"] >> rgbDistCoeffs;

FileStorage irCamSettings("camera_ir.yml", CV_STORAGE_READ);
Mat irCameraMatrix;
Mat irDistCoeffs;
irCamSettings["camera_matrix"] >> irCameraMatrix;
irCamSettings["distortion_coefficients"] >> irDistCoeffs;


Mat cameraMatrix[2], distCoeffs[2];
cameraMatrix[0] = rgbCameraMatrix;
cameraMatrix[1] = irCameraMatrix;
distCoeffs[0] = rgbDistCoeffs;
distCoeffs[1] = irDistCoeffs;

Mat R, T, E, F;



double rms = stereoCalibrate(objectPoints, imagePoints[0], imagePoints[1],
                cameraMatrix[0], distCoeffs[0],
                cameraMatrix[1], distCoeffs[1],
                imageSize, R, T, E, F,
                TermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 50, 1e-6),
                CV_CALIB_FIX_INTRINSIC +
                CV_CALIB_USE_INTRINSIC_GUESS
                );

推荐答案

在Dropbox上看不到图像(为什么不将图像放在堆栈交换中?),但似乎束调整未收敛.您应该尝试以下操作:

Can't see your images on Dropbox (why not put your images on stack exchange?), but it seems like the bundle adjustment does not converge. You should try the following:

  1. 使用cv::calibrateCamera(链接),然后获取每个摄像机的摄像机矩阵K和失真系数D.

  1. Calibrate each camera independently using cv::calibrateCamera (link) and get the camera matrix K and distortion coefficients D for each camera.

使用cv::stereoCalibrate(链接),其中包含估算的K和D并启用了标志CV_CALIB_USE_INTRINSIC_GUESSCV_CALIB_FIX_INTRINSIC.

Estimate the rotation R and the translation T between the two cameras using cv::stereoCalibrate (link) with the estimated K and D and with flags CV_CALIB_USE_INTRINSIC_GUESS and CV_CALIB_FIX_INTRINSIC enabled.

这样做将使摄像机矩阵的估计和失真系数与旋转和平移的估计脱钩,这将大大改善残余误差.

Doing so will decouple the estimation of both camera matrices and distortion coefficients from the estimation of the rotation and translation, which should improve the residual error a lot.

这篇关于对不同摄像机(RGB和红外)进行校准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 21:34