如何在 C++ 中使用向量<Point2f>

Rah*_*hul 1 c++ opencv

我想使用此代码(源代码)在opencv中查找基本矩阵。

\n\n
int point_count = 100;\n    vector<Point2f> points1(point_count);\n    vector<Point2f> points2(point_count);\n\n    // initialize the points here ... */\n    for( int i = 0; i < point_count; i++ )\n    {\n        points1[i] = ...;\n        points2[i] = ...;\n    }\n\n    Mat fundamental_matrix =\n     findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99);\n
Run Code Online (Sandbox Code Playgroud)\n\n

但我不知道如何在for循环中初始化points1、point2。\n我尝试过使用:

\n\n
points1[i] = 10.0;\npoints1[i] = (10.0, 20.0);\npoints1[i] = {10.0, 20.0};\n
Run Code Online (Sandbox Code Playgroud)\n\n

但出现这样的错误

\n\n
no match for \xe2\x80\x98operator=\xe2\x80\x99 (operand types are \xe2\x80\x98cv::Point_<float>\xe2\x80\x99 and \xe2\x80\x98double\xe2\x80\x99)\n
Run Code Online (Sandbox Code Playgroud)\n\n

在所有这些中。

\n

Mo *_*eed 6

它们应该像下面这样初始化:

points[i] = Point2f(0.3f, 0.f);
Run Code Online (Sandbox Code Playgroud)

检查 OpenCV文档