Closed valioiv closed 2 years ago
Hello,
Are the nine R and T's returned from cv.calibrateCamera
or cv.stereoCalibrate
? It looks like it is from cv.calibrateCamera
. If it is, then in my blog post, we discard the R and T values from this step and use the camera matrix in the cv.stereoCalibrate
call. Then cv.stereoCalibrate
returns R and T that takes points in camera0 space to camera1 space.
If you put in any of the R and T pairs you obtained from your 9 images into rot_trans_c0.dat, then you are picking one of the images, or rather the position of the calibration pattern, as your worldspace origin point. That means all 3D points obtained from triangulation will be with respect to this origin point defined by the calibration pattern. In any case, this is what you need to do to get working calibration matrices:
World space origin defined by calibration pattern
cv.calibrateCamera
in rot_trans_c0.dat. We will call these R0 and T0.cv.stereoCalibrate
to obtain R and T that performs coordinate transform from cam0 to cam1. We will call these R01 and T01 to indicate these are used to translate points from cam0 coordinate frame to cam1 coordinate frame.R1 = R01 @ R1
T1 = R01 @ T0 + T01
(@ means matrix multiply)
Then put R1 and T1 into rot_trans_c1.datIn my blog post, I simply select R0 as identity matrix and T0 as zeros vector. This essentially chooses world space origin to overlap with cam0 coordinates.
On a side note, you have an rmse of 1.6. This is too high in my opinion. You should aim to obtain less than 1. A very good calibration should be less then 0.2 and acceptable level will be about 0.5. The calibration pattern should be printed on a large sheet and it should be as flat as you can make it. The calibration steps are very sensitive to small distortions in the calibration pattern.
@TemugeB , I'm so sorry for the delay. Now I can confirm that based on your recommendations I managed to make proper calibration! I just put world space origin to match with cam0 coordinates and it works perfectly fine! The main problem was that I had bad (and missing) images during the image gathering before the actual calibration and this was the reason for the bad RMSE and many other matrix issues. Redone the capturing of the images, recalibrate and now everything is up and running great!
Hi, sorry for asking here again but I don't get what to put inside rot_trans_cX.dat configuration file especially for "R" and T:
For "R" I can see there 3 lines of 3 coefficients each. But I've run the calibration script ( https://temugeb.github.io/opencv/python/2021/02/02/stereo-camera-calibration-and-triangulation.html )on 9 images from each one of the two cameras and this is the output for the left camera:
Same as text:
Do I need to put in the rot_trans_cX.dat file all the 9 arrays like that or I need to put just some random 3 of them? This is what I currently have (I've selected random 3 of them):
Is it correct? What about "T" ?