Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV (python) fundamental and essential matrix do not agree

I try to calibrate a stereo camera with OpenCV (python interface). I first calibrated the two cameras separately with calibrateCamera2 and then fed the parameters to stereoCalibrate

cv.StereoCalibrate(object_points, image_points_left, image_points_right, \
               point_counts, intrinsic_left, distortion_left,\
               intrinsic_right, distortion_right, \
               (IMGRES_X,IMGRES_Y), R, T, E, F, \
               term_crit=(cv.CV_TERMCRIT_ITER+cv.CV_TERMCRIT_EPS, 100, 1e-8),\
               flags=cv.CV_CALIB_FIX_INTRINSIC)

I check the result with the epipolar constraint (as described in the OpenCV book) and get an average error of around 0.0039.

In principle I should be able to relate the fundamental and the essential matrix with my camera matrices. So what I do is:

Mr = asarray(intrinsic_right,dtype=float64)
Ml = asarray(intrinsic_left,dtype=float64)
E = asarray(E)
F = asarray(F)
F2 = dot(dot(inv(Mr).T,E),inv(Ml))

However, the resulting matrix F2 does not at all resemble F. Is there something obvious that I am doing wrong? Help is much appreciated.

Edit: dot and inv are from numpy.

like image 740
fabee Avatar asked Oct 20 '25 06:10

fabee


1 Answers

The E and F matrices returned by StereoCalibrate() are correct. F is defined up to scale, hence if you're going to compare the returned F and with the F matrix computed from E you need to normalize them to make sure both are at the same scale. So when you look at them they seem the same. StereoCalibrate() normalizes the returned F, thus you need to normalize the computed F2 as you have noted in one of your comments. I hope that makes it more clear why you need to do so.

like image 110
fireant Avatar answered Oct 21 '25 21:10

fireant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!