# Calibrate at one resolution, remap at another resolution?

According to the docs, since the distortion coefficients do not depend on the resolution, I should be able to make use of the camera calibration data with a different resolution (from that which was used during calibration).

Unfortunately I haven't be able to make this work. Is there an example out there that makes use of initUndistortRectifyMap() and remap() when the original camera matrix and distortion coefficients were gathered at a different resolution from the image being passed to remap() ?

Thanks!

edit retag close merge delete

Sort by ยป oldest newest most voted

Got this working after posting:

  Mat newCamMatrix = calibCamMatrix.clone();
double scale = double(newWidth) / double(calibWidth);
newCamMatrix.at<double>(0,0) = scale * calibCamMatrix.at<double>(0,0);
newCamMatrix.at<double>(1,1) = scale * calibCamMatrix.at<double>(1,1);
newCamMatrix.at<double>(0,2) = scale * calibCamMatrix.at<double>(0,2);
newCamMatrix.at<double>(1,2) = scale * calibCamMatrix.at<double>(1,2);


calibCamMatrix is the matrix generated by the calibration process (where frame had x resolution of calibWidth). newCamMatrix is the modified matrix to be passed to initUndistortRectifyMap(), along with the new resolution (newWidth/yyy)

more

You can replace the individual = scale * statements with newCamMatrix *= scale;

( 2016-07-11 13:32:58 -0600 )edit

Oops. Forgot one thing. After scaling, you need newCamMatrix.at<double>(2,2) = 1.

( 2016-07-11 14:58:18 -0600 )edit

Nifty. Thanks for the cleaner code. :)

( 2016-07-11 15:40:20 -0600 )edit

Official site

GitHub

Wiki

Documentation