Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Cropping Calibration Correction maps

Hello, we have a system with a number of cameras.

At run-time, one of those cameras has a very small ROI in the y-direction: 6-20 lines.

This is (much) too small to use a grid to calibrate the camera; but I can do that using a full field of view and just crop.

But: if I use initUndistortRectifyMap to get mapx & mapy, how do I crop them?

Mapx looks pretty obvious (I think!), I crop to the ROI and then subtract the offset ie:

 initUndistortRectifyMap(cameraMatrix, distCoeffs, R1, cameraMatrix, 
                         Size(cameraSensorX, cameraSensorY), CV_16SC2, 
                         distCorrectMapXY, distCorrectMapY);

 Mat distCorrectMapXYROI_orig, distCorrectMapXYROI_offset, distCorrectMapYROI;

 distCorrectMapXYROI_orig = distCorrectMapXY(
                             Range(cameraYOffset, cameraYOffset + cameraYROI), 
                             Range(cameraXOffset, cameraXOffset + cameraXROI));

  vector <Mat> distCorrectMapsXYROI_split;
  split(distCorrectMapXYROI_orig, distCorrectMapsXYROI_split);

  distCorrectMapsXYROI_split[0] -= cameraXOffset;
  distCorrectMapsXYROI_split[1] -= cameraYOffset;

  merge(distCorrectMapsXYROI_split, distCorrectMapXYROI_offset);

Are my assumptions with mapx correct?

Next, what do I do with mapy? Its not so obvious. Right now I'm just cropping and it seems OK?

 distCorrectMapYROI = distCorrectMapY(
                      Range(cameraYOffset, cameraYOffset + cameraYROI),
                      Range(cameraXOffset, cameraXOffset + cameraXROI));

Thanks for everyone's help.

Gunter