问题
Why does rectification work like this? Please can someone explain me it in details? How does extrinsic parameter affect rectification result?
1) I build the set of stereo cameras where I can rotate them as I want to. My input images: 2) I calibrated them using Matlab and confirmed by Kalibr method. So I assume that I know perfect intrinsic, distortion and extrinsic parameters.
3) I implemented rectification based on openCV 2.4.13 and Matlab as reference. My translation express in meters [0.13 0.003 0.003]. My rectified images:
4) However I would like to understand the impact of translation parameters. I started experiments with different values. I notice that when I set a translation between cameras to vector [0, 0 ,0] image was a little bit wider in range but has the same size ( we may see a little bit more on the top of image) image below:
5) When I changed translation on [2 0.5 0.2]
6) When I changed translation on [140 3 3] so in scale of millimeters. It seems show that the scale factor has not big impact on rectification process. I think that in depth analyses it will has a big impact.
For all of images alpha parameter was equal 0. The openCV results are close to Matlab functions from the similar functionality (image below).
Finally could someone explain me how the translation and rotation (extrinsic) parameters implicate on rectification process and correct this epipolar geometry? Below is the way that I implemented my program and some of my remarks.
I checked some literature but still I didn't find clear answer:
A compact algorithm for rectification of stereo pairs
Szeliski's book page 538
I initialize all parameters:
parameters = cv::Mat::zeros(height1, width1, CV_64FC1); parameters.at<double>(0,0) = fx;
First - I found important issues that all parameters have to be double. Second - that nb 1 refereed to camera right which is express in left frame camera coordinates. I call the:
C++: void stereoRectify(InputArray cameraMatrix1, InputArray distCoeffs1, InputArray cameraMatrix2, InputArray distCoeffs2, Size imageSize, InputArray R, InputArray T, OutputArray R1, OutputArray R2, OutputArray P1, OutputArray P2, OutputArray Q, int flags=CALIB_ZERO_DISPARITY, double alpha=-1, Size newImageSize=Size(), Rect* validPixROI1=0, Rect* validPixROI2=0 )
I played with all parameters. After:
C++: void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs, InputArray R, InputArray newCameraMatrix, Size size, int m1type, OutputArray map1, OutputArray map2)
I remap:
C++: void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())
Finally my program looks very similar to this. Here is documentation to openCV.
For Matlab:
[J1, J2] = rectifyStereoImages(I1, I2, stereoParams);
Thanks for your time and answers. Regards.
来源:https://stackoverflow.com/questions/48341953/how-does-parameters-impact-on-rectification-process