I have a pair of horizontally aligned stereo cameras which were calibrated using the full size of the images.
I'm rectifying by calling cv2.initUndistortRectifyMap to get the map for each camera, and then cv2.remap
When using the full size images, this looks like:
map1, map2 = cv2.initUndistortRectifyMap(camera_matrix_1, dist_coeffs_1, R1, P1, (w, h), cv2.CV_16SC2)
map3, map4 = cv2.initUndistortRectifyMap(camera_matrix_2, dist_coeffs_2, R2, P2, (w, h), cv2.CV_16SC2)
rectified1 = cv2.remap(img1, map1, map2, cv2.INTER_LINEAR)
rectified2 = cv2.remap(img2, map3, map4, cv2.INTER_LINEAR)
Where the parameters for cv2.initUndistortRectifyMap
are the output of cv2.stereoCalibrate
and cv2.stereoRectify
For improving processing speed however, the images will be cropped (and potentially binned) when processing, before they can be rectified. Which means that the rectification process can't use the full size of the image.
What needs to be changed to get the code to work with cropping (and binning) of the images before the rectification is done?