如何在c ++中使用vector <point2f>

时间:2016-11-03 18:00:07

标签: c++ opencv

我想使用此代码(source)在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);

但我不知道如何初始化for循环中的points1,points2。 我尝试过使用:

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

但是得到这样的错误

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

所有这些。

1 个答案:

答案 0 :(得分:1)

它们应该如下初始化:

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

检查OpenCV documentation