gpt4 book ai didi

c++ - cv::findHomography gioving错误c2665

转载 作者:太空宇宙 更新时间:2023-11-04 14:13:14 24 4
gpt4 key购买 nike

我看了这段代码,它给出了 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' : 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.

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

最佳答案

vector 声明后不应该有括号。您的代码应为:

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

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

我假设您没有用点填充 vector 。否则,请在将它们放入 findHomography 之前执行此操作。您编写的代码将空 vector 作为参数传递。

关于c++ - cv::findHomography gioving错误c2665,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13145500/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com