1

I looked at this code which gives 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 );

So naturally I wanted to load data into findHomography the same way. So my code reads

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

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

But its giving me

1>c:\main.cpp(65): error C2665: 'cv::findHomography' : none of the 2 overloads could convert all the argument types 1> c:\opencv\build\include\opencv2\calib3d\calib3d.hpp(423): could be 'cv::Mat cv::findHomography(cv::InputArray,cv::InputArray,int,double,cv::OutputArray)' 1> c:\opencv\build\include\opencv2\calib3d\calib3d.hpp(428): or 'cv::Mat cv::findHomography(cv::InputArray,cv::InputArray,cv::OutputArray,int,double)' 1> while trying to match the argument list '(overloaded-function, overloaded-function, int)' 1> 1>Build FAILED.

It works if I use CV::Mat instead of Vectors but I don't understand why the same format as in the sample shouldn't want to work.

4

1 回答 1

0

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

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

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

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

于 2012-10-30T22:47:59.420 回答