Ask Your Question

Calibrate at one resolution, remap at another resolution?

asked 2016-07-01 14:46:53 -0600

logidelic gravatar image

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() ?


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-07-04 08:12:03 -0600

logidelic gravatar image

updated 2016-07-11 15:36:14 -0600

Got this working after posting:

  Mat newCamMatrix = calibCamMatrix.clone();
  double scale = double(newWidth) / double(calibWidth);<double>(0,0) = scale *<double>(0,0);<double>(1,1) = scale *<double>(1,1);<double>(0,2) = scale *<double>(0,2);<double>(1,2) = scale *<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)

edit flag offensive delete link more


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

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

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

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

Nifty. Thanks for the cleaner code. :)

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

Question Tools

1 follower


Asked: 2016-07-01 14:46:53 -0600

Seen: 1,414 times

Last updated: Jul 11 '16