Ask Your Question
0

Cropping Calibration Correction maps

asked 2014-05-12 07:43:56 -0500

Gunter gravatar image

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

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-05-14 07:54:47 -0500

Gunter gravatar image

With fresh eyes it was easy to find the easy approach, call, instead:

 initUndistortRectifyMap(cameraMatrix, distCoeffs, R1, cameraMatrix, 
                         Size(cameraSensorX, cameraSensorY), **CV_32FC1**, 
                         distCorrectMapX, distCorrectMapY);

Then you get all the X in MapX and all the Y in the MapY. Then just subtract the offset from each.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-05-12 07:43:56 -0500

Seen: 319 times

Last updated: May 14 '14