1

I want to use this code(source) to find fundamental matrix in opencv.

int point_count = 100;
    vector<Point2f> points1(point_count);
    vector<Point2f> points2(point_count);

    // initialize the points here ... */
    for( int i = 0; i < point_count; i++ )
    {
        points1[i] = ...;
        points2[i] = ...;
    }

    Mat fundamental_matrix =
     findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99);

but I don't know how to initialise points1, points2 in for loop. I have tried using:

points1[i] = 10.0;
points1[i] = (10.0, 20.0);
points1[i] = {10.0, 20.0};

but getting error like this

no match for ‘operator=’ (operand types are ‘cv::Point_<float>’ and ‘double’)

in all of them.

Fantastic Mr Fox
  • 32,495
  • 27
  • 95
  • 175
Rahul
  • 262
  • 1
  • 5
  • 22

1 Answers1

6

They should be initialized like the following:

points[i] = Point2f(0.3f, 0.f);

Check OpenCV documentation.

Mo Abdul-Hameed
  • 6,030
  • 2
  • 23
  • 36
  • I tried your solution and not getting any errors in points[i] = Point2f(0.3f, 0.f); but getting this error in Mat fundamental_matrix;, undefined reference to `cv::findFundamentalMat(cv::_InputArray const&, cv::_InputArray const&, int, double, double, cv::_OutputArray const&)' – Rahul Nov 03 '16 at 18:11
  • This is a linking error, you're not linking with the implementation of the function `cv::findFundamentalMat`. – Mo Abdul-Hameed Nov 03 '16 at 18:21
  • As suggested by Ben, it's better to ask a new question about the new issue. – Mo Abdul-Hameed Nov 03 '16 at 18:40
  • Code from the documentation: `Point_(_Tp _x, _Tp _y); typedef Point_ Point2f;`. Why he needs to invoke the constructor *explicitly* when there is no `explicit` keyword with the constructor? – Saurav Sahu Nov 03 '16 at 19:18