I am trying to restore camera movement using the fundamental matrix and algorithm provided on Wikipedia . For this I need to find a fundamental matrix. I use
OpenCV::findFundamentalMatfor this.
Two unexpected behaviors:
- The use of different fitting algorithms gives different results, especially
FM_8POINTdifferent. - Given a set of pairs of points (y, x), yFx = 0 is not satisfied and is always greater than 0.
Didn’t I understand something? Is my example false or what is going on? Can anyone suggest a better test case?
Below is a minimal example. Create 12 artificial points, move each of these points 10 pixels to the right, find the main matrix of these two sets of points and print yFxfor each point.
Example:
int main(int argc, const char* argv[])
{
std::vector<cv::Point2f> pts1, pts2;
for(double y = 0; y < 460; y+=150)
{
for(double x= 0; x < 320; x += 150)
{
pts1.push_back(cv::Point2f(x, y));
pts2.push_back(cv::Point2f(x+10.0, y));
}
}
cv::Mat F = cv::findFundamentalMat(pts1, pts2);
for(int i = 0; i < pts1.size(); i++)
{
cv::Mat p1(3,1, CV_64FC1), p2(3,1, CV_64FC1);
p1.at<double>(0) = pts1.at(i).x;
p1.at<double>(1) = pts1.at(i).y;
p1.at<double>(2) = 1.0;
p2.at<double>(0) = pts2.at(i).x;
p2.at<double>(1) = pts2.at(i).y;
p2.at<double>(2) = 1.0;
cout << p1.t() * F * p2 << endl;
}
}
For FM_RANSACi get
[1.999], [2], [2], [1.599], [1.599], [1.599], [1.198], [1.198], [1.198], [0.798], [0.798], [0.798]
For FM_8POINTthe fundamental matrix zeros(3,3)and, consequently, yFxis 0 for all y, x.
I just found: estimating T and R from the main matrix , but that didn't help much.
Edit : yFx- wrong round path ( p1/ p2included in cout-line). This example also does not work, because all points lie on the plane.