I'm trying to undistort the output of a pair of cameras using the following OpenCV functions:
cv::stereoCalibrate(object_points, image_points_left, image_points_right,cameraMatrixLeft, distCoeffsLeft, cameraMatrixRight, distCoeffsRight,cv::Size(sensor_width, sensor_height),R, T, E, F);
cv::stereoRectify(cameraMatrixLeft, distCoeffsLeft, cameraMatrixRight, distCoeffsRight, cv::Size(sensor_width, sensor_height), R, T, R1, R2, P1, P2, Q);
cv::undistortPoints(src_left, dst_left, cameraMatrixLeft, distCoeffsLeft, R1, P1);
cv::undistortPoints(src_right, dst_right, cameraMatrixRight, distCoeffsRight, R2, P2);
As I understand, the function cv::undistortPoints
should also rectify the output using the matrices R1
, R2
, P1
and P2
according to my stereo camera setup, i.e. set the epipolar lines parallel to the image y-axis and crop the image.
Is this correct?
However, the mapping performed on the points in src_left
and src_right
is "tilted", i.e. the undistorted output images are tilted, leaving blank spaces on the boarders (especially in half of the corners) of the image. I believe this tilting comes from the rotation matrices R1
and R2
and corresponds to the rotations around the z-axis.
Now here is my question:
- Why do the (rectified) output images not fill the whole image space?