Ask Your Question

How to use five-point.cpp

asked 2013-07-26 07:27:27 -0500

Guido gravatar image

Hi there,

I notice a nice little function has appeared in opencv : five-point.cpp. However I can't figure how to use the various functions inside. Is there an example available ? If the functions are not mature yet, I would be glad to test them.

Best regards,


edit retag flag offensive close merge delete


The 5-Point algorithm returns 10 solutions for E. I am facing this problem as I am trying to implement this algorithms for my academic project. 1. Which Matrix out of the 10 solutions to be choosen as the Essential Matrix. What's the criteria for that? 2. How to generalize the 5-point algorithm for more than 5 points(RANSAC inliers) for final Motion Estimation. Thank you in advance for any help in this issue.

with best regards, Durga Prasad.

Prasad_MyWay gravatar imagePrasad_MyWay ( 2016-02-25 03:10:42 -0500 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2013-07-26 08:37:18 -0500

berak gravatar image

the public declaration of the functions is in calib3d.hpp, so no problem accessing them.

docs ? hmm. found none ( maybe they're just waiting for you to write them ? )

findFundamentalMat is used in the stereocalibration samples, and there's some testcode

edit flag offensive delete link more


Nice, thanks. I too wonder why there is no doc.

Guido gravatar imageGuido ( 2013-07-26 09:15:18 -0500 )edit

answered 2013-07-26 10:10:49 -0500

RaulPL gravatar image

five-point.cpp is the file that provides functions to calculate the Essential matrix (a special case of the Fundamental matrix) using the five point algorithm. The findEssentialMat function is similar to findFundamentalMat, the difference is that you require the intrinsic parameters of your camera (calculated from calibration). You need to provide the following:

  1. p1: points of the image 1 (vector<point2f> or Mat)
  2. p2: points of the image 2 (vector<point2f> or Mat)
  3. focal: focal distance (double), it is the element (0,0) of your intrinsic parameters matrix.
  4. pp: principal point (Point2d), this vector must have the elements (0,2) and (1,2) of the intrinsic parameters matrix.
  5. method: in this case it could be RANSAC or LMeDS (similar to findFundamentalMat)
  6. probability of success: usually 0.99
  7. error: this value is the threshold used in RANSAC to determine if a match is considered an outlier or an inlier
  8. output: a matrix that contains ones and zeros, indicates which correspondences are outliers using a zero and inliers using a one.


     Mat essential = findEssentialMat(p1,p2,focal,pp,RANSAC,0.99,1,output);
edit flag offensive delete link more


Thank you for this documentation. Do you think you could manage to get this on the opencv site ?

Guido gravatar imageGuido ( 2013-08-01 07:02:21 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2013-07-26 07:27:27 -0500

Seen: 1,759 times

Last updated: Jul 26 '13