Ask Your Question
1

How do I compute the fundamental matrix from 2 projection matrices?

asked 2017-03-02 16:14:07 -0600

ad05 gravatar image

Supposed I have 2 projection matrices in the form of P1 (3x4 matrix) and P2 (3x4) matrix, is there a function in opencv that could compute the fundamental matrix?

Apparently there's a function called fundamentalFromProjections: [http://docs.opencv.org/trunk/d7/d15/g...]) but I couldn't find it in opencv in python.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2017-03-02 19:12:46 -0600

Tetragramm gravatar image

The sfm module is difficult to compile with a lot of dependencies, but the code is still in the opencv_contrib repository. This method is simple enough.

https://github.com/opencv/opencv_contrib/blob/master/modules/sfm/src/fundamental.cpp#L109

edit flag offensive delete link more

Comments

Thing is I don't know C++ very well, so how do I translate this into a python function?

ad05 gravatar imagead05 ( 2017-03-03 07:59:44 -0600 )edit

Well, the vconcat function is the same as numpy vstack. The (i,j) access is the same as numpy's .item(i,j). And determinant is numpy.linalg.det.

I assume you know how to access one row of data, and create the 3x3 double or float output.

Tetragramm gravatar imageTetragramm ( 2017-03-03 18:40:43 -0600 )edit

what about X[3], Y[3], X[0], Y[0] ? what are those?

ad05 gravatar imagead05 ( 2017-03-07 12:15:27 -0600 )edit

Array accesses. It makes an array of Mat_<t> called X and Y, and it's just like a python array. The Mat_<t> can be replaced with a numpy array of the appropriate type.

Tetragramm gravatar imageTetragramm ( 2017-03-07 17:22:15 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2017-03-02 16:14:07 -0600

Seen: 2,626 times

Last updated: Mar 02 '17