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.
You should not have parentheses after your vector declarations. Your code should read:
std::vector<cv::Point2f> srcPoints;
std::vector<cv::Point2f> dstPoints;
cv::Mat homography = cv::findHomography(srcPoints, dstPoints, CV_RANSAC);
I assume you left out filling the vectors with points. Otherwise, do so before putting them through findHomography
. Your code as written passes empty vectors as arguments.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.