# Effect of flag parameter in stereoRectify()

I'm using the stereoRectify() function to rectify stereo image pairs in advance of doing stereo matching. However, I'm struggling to understand exactly what the 'flags' parameter does. The documentation has the following to say:

"Operation flags that may be 0 or CV_CALIB_ZERO_DISPARITY . If the flag is set, the function makes the principal points of each camera have the same pixel coordinates in the rectified views. And if the flag is not set, the function may still shift the images in the horizontal or vertical direction (depending on the orientation of epipolar lines) to maximize the useful image area."

From this, and the explanation in the Learning OpenCV book, my understanding is that passing the CV_CALIB_ZERO_DISPARITY flag leads to the canonical geometry where the 2 image planes are co-planar, the optical axes are parallel, and a disparity of 0 occurs for points at infinity. On the other hand, passing a flag of 0 means that the rectification leaves the virtual rectified cameras pointing slightly inwards, and hence having their optical axes intersect at a finite point.

My questions are:

1. When a flag of 0 is passed, what determines the angling of the rectified cameras (how is the finite intersection point determined?)
2. If the cameras are angled slightly inwards, will this lead to poorer stereo matching accuracy, because the epipolar lines are no longer horizontal (and hence aligned to image rows)?
edit retag close merge delete