Ask Your Question
0

Reprojection error with findFundamentalMat

asked 2015-01-28 07:44:52 -0600

Eduardo gravatar image

updated 2015-01-29 03:47:57 -0600

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[0]*f.x + F[1]*f.y + F[ 2]*f.z + F[ 3] - t.x;
double b = F[4]*f.x + F[5]*f.y + F[ 6]*f.z + F[ 7] - t.y;
double c = F[8]*f.x + F[9]*f.y + F[10]*f.z + F[11] - 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 flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-02-19 06:44:39 -0600

Eduardo gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-01-28 07:44:52 -0600

Seen: 2,749 times

Last updated: Feb 19 '15