【问题标题】:cv::findHomography gioving error c2665cv::findHomography gioving 错误 c2665
【发布时间】:2012-10-20 04:14:18
【问题描述】:

我查看了这段代码 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 );

所以很自然地,我想以同样的方式将数据加载到 findHomography 中。 所以我的代码是

std::vector<cv::Point2f> srcPoints();
std::vector<cv::Point2f> dstPoints();

cv::Mat homography = cv::findHomography(srcPoints, dstPoints, CV_RANSAC);

但它给了我

1>c:\main.cpp(65): error C2665: 'cv::findHomography' : 2 个重载都不能转换所有参数类型 1> c:\opencv\build\include\opencv2\calib3d\calib3d.hpp(423): 可能是 'cv::Mat cv::findHomography(cv::InputArray,cv::InputArray,int,double,cv: :输出数组)' 1> c:\opencv\build\include\opencv2\calib3d\calib3d.hpp(428): 或 'cv::Mat cv::findHomography(cv::InputArray,cv::InputArray,cv::OutputArray,int,双倍的)' 1> 在尝试匹配参数列表“(重载函数,重载函数,int)”时 1> 1>构建失败。

如果我使用 CV::Mat 而不是 Vectors,它会起作用,但我不明白为什么与示例中相同的格式不应该起作用。

【问题讨论】:

    标签: c++ opencv homography


    【解决方案1】:

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

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

    我假设您没有用点填充向量。否则,请在将它们通过findHomography 之前这样做。您编写的代码将空向量作为参数传递。

    【讨论】:

      猜你喜欢
      • 2012-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-02
      • 2012-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多