Ask Your Question
0

Calibrate at one resolution, remap at another resolution?

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

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

Thanks!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

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

logidelic gravatar image

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

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)

edit flag offensive delete link more

Comments

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

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

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

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

Nifty. Thanks for the cleaner code. :)

logidelic gravatar imagelogidelic ( 2016-07-11 15:40:20 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 514 times

Last updated: Jul 11 '16