How to calculate the fundamental matrix for stereo vision

I am trying to write code that will calculate the fundamental matrix to determine the relationship between stereo images. I started with the books of Hartley and Sisserman, which most people recommend, but he did not have practical examples, and the code example for him was in MATLAB, which I do not have. Then I switched to an introduction to 3D methods and algorithms of computer vision , which is more practical and has actual examples in it. I implemented the recommended 8-point algorithm using Python and numpy, but I had trouble checking its validity.

I use the dataset listed on page 48 (use this link above to see an excerpt from Google Books) of this book. When I normalize glasses, I get the same results as this book. However, when I use the numpy SVD function to calculate the main matrix, I get the following value for F:

[[-0.01851684 -0.21631176 -0.67036356] [ 0.2605251 -0.01023853 0.14234079] [ 0.63748775 -0.09404508 -0.00220713]] 

This matrix satisfies the equation p_R ^ * F * p_L = 0 , therefore it seems correct. However, it is very different from the matrix calculated in the book. I tried double checking the answer using OpenCV cv.FindFundamentalMat () and I got the third answer:

 [[ 22.98129082 271.46453857 853.74273682] [-334.1673584 -4.84123087 -175.99523926] [-809.88891602 125.99833679 1. ]] 

I’m not the way these two other matrices are calculated, but I can’t find examples of calculating the fundamental matrix in the network to test my implementation of the 8-point algorithm. The fact that my implementation returns a value that satisfies the equation gives me confidence, but I'm worried that I did something stupid, so I cannot compare the results in a book or OpenCV.

+6
opencv computer-vision stereo-3d
source share
1 answer

Please note that the fundamental matrix is ​​determined up to a constant factor (you can check this quite easily by checking the epipolar constraint). Try multiplying the OpenCV matrix by -8.0574e-04, and you will see that in the end the two matrices are very similar :-)

So your result is probably perfect. The slight difference between the results is probably due to the fact that OpenCV uses a different (probably more reliable) approach than the 8-point algorithm.

+5
source share

All Articles