cv::findHomography gioving error c2665



我查看了此代码http://docs.opencv.org/doc/tutorials/features2d/feature_homography/feature_homography.html

//-- Localize the object
std::vector<Point2f> obj;
std::vector<Point2f> scene;
for( int i = 0; i < good_matches.size(); i++ )
{
    //-- Get the keypoints from the good matches
    obj.push_back( keypoints_object[ good_matches[i].queryIdx ].pt );
    scene.push_back( keypoints_scene[ good_matches[i].trainIdx ].pt );
}
Mat H = findHomography( obj, scene, CV_RANSAC );

所以自然而然地,我想以相同的方式将数据加载到findomography中。所以我的代码读取

std::vector<cv::Point2f> srcPoints();
std::vector<cv::Point2f> dstPoints();
cv::Mat homography = cv::findHomography(srcPoints, dstPoints, CV_RANSAC);

但是它给了我

1> c: main.cpp(65):错误c2665:'cv :: findHomography':这两个超载都不能转换所有参数类型 1> c: opencv build include opencv2 calib3d calib3d.hpp(423):可以是'cv :: mat cv :: findhomography(cv :: inputArray,cv :: cv :: inputArray,cv :: inputArray,inputArray,int,int,int,double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,double,dow:outputarray)'' 双倍的)' 1>尝试匹配参数列表'(超载功能,超载功能,int)' 1> 1>构建失败。

如果我使用cv :: mat而不是向量,它可以正常工作,但我不明白为什么与示例中不想使用的格式相同。

您在向量声明后不应有括号。您的代码应读取:

std::vector<cv::Point2f> srcPoints;
std::vector<cv::Point2f> dstPoints;
cv::Mat homography = cv::findHomography(srcPoints, dstPoints, CV_RANSAC);

我假设您没有点填充向量。否则,请在将它们放置在findHomography之前。您的书面代码将空向量作为参数传递。

最新更新