# Reprojection error with findFundamentalMat

Hello,

Maybe my question is not really appropriate here.

As the function findFundamentalMat (with a RANSAC method) does not return the list of outliers, I was trying to use the fundamental matrix returned by the function to compute myself the reprojection error for the input points.

I looked into the source code and I discovered that there is a function called findInliers which call computeError to compute the error for the input points using the fundamental matrix estimated in the current iteration. When I checked this function:

const Point3f* from = m1.ptr<Point3f>();
const Point3f* to = m2.ptr<Point3f>();
const double* F = model.ptr<double>();

for(int i = 0; i < count; i++ )
{
const Point3f& f = from[i];
const Point3f& t = to[i];
double a = F*f.x + F*f.y + F[ 2]*f.z + F[ 3] - t.x;
double b = F*f.x + F*f.y + F[ 6]*f.z + F[ 7] - t.y;
double c = F*f.x + F*f.y + F*f.z + F - t.z;
errptr[i] = (float)std::sqrt(a*a + b*b + c*c);
}


for me model is the current estimated fundamental matrix which seems to have 12 elements instead of being a 3x3 matrix. Is there a problem or am I missing something ? Can someone explain me the formula for computing the error ?

To compute the error, I think I will use the distance error between the real 2d location in the image to the corresponding epipolar line using the fundamental matrix for each input points, but I want to understand what is behind the formula used in the source code of OpenCV.

Thanks.

Edit: I was wrong, findFundamentalMat returns also the list of inliers in a cv::Mat with the C++ interface.

edit retag close merge delete

Sort by » oldest newest most voted

I was utterly wrong. I don't know what happened in my mind at this time but I looked at the wrong function to compute the error.

The part of code I quoted comes from the function (computeError) for Affine3DEstimator and compute the error distance vector for two sets of 3D points and with the estimated 3D affine transformation matrix.

The correct function called to compute the distance error to find inliers with Ransac findFundamentalMat is this one. In this case, the distance error is the maximum squared distance between the 2D image point and the corresponding epipolar line between the left and the right images.

more

Official site

GitHub

Wiki

Documentation