2013-05-09 69 views
2

你好,我想实现快速特征检测器的代码,在它的初始阶段,我得到了以下错误比如在OpenCV的重载函数

(1)没有重载函数“CV :: FastFeatureDetector的实例: :检测”相匹配的参数列表

(2) “KeyPointsToPoints” 未定义

请帮助我。

#include <stdio.h> 
#include "opencv2/core/core.hpp" 
#include "opencv2/features2d/features2d.hpp" 
#include "opencv2/highgui/highgui.hpp" 
#include "opencv2/nonfree/nonfree.hpp" 
using namespace cv; 
int main() 
{ 
    Mat img1 = imread("0000.jpg", 1); 
    Mat img2 = imread("0001.jpg", 1); 
// Detect keypoints in the left and right images 
FastFeatureDetector detector(50); 
Vector<KeyPoint> left_keypoints,right_keypoints; 
detector.detect(img1, left_keypoints); 
detector.detect(img2, right_keypoints); 
vector<Point2f>left_points; 
KeyPointsToPoints(left_keypoints,left_points); 
vector<Point2f>right_points(left_points.size()); 

return 0; 
} 
+0

你的OpenCV版本的文档对'cv :: FastFeatureDetector :: detect'说了些什么? – juanchopanza 2013-05-09 13:37:28

回答

7

的问题是在这条线:

Vector<KeyPoint> left_keypoints,right_keypoints; 

C++是区分大小写的,它看到Vector的东西比vector(它确实应该)不同。为什么Vector的工作超出了我的想象,我早就预料到了一个错误。

cv::FastFeatureDetector::detect只知道如何使用vector而不是Vector,因此请尝试修复此错误并重试。

此外,在OpenCV库中不存在KeyPointsToPoints(除非您自己编写它),请确保使用KeyPoint::convert(const vector<KeyPoint>&, vector<Point2f>&)进行转换。

0

给出的代码有几个小问题。首先,你错过了using namespace std,这正是你使用它们的方式所需要的。您也错过了包含载体#include <vector>vector<KeyPoints>也应该有一个小写v。我也不确定KeyPointsToPoints是否是OpenCV的一部分。你可能必须自己实现这个功能。我不确定,我以前没有见过。

#include <stdio.h> 
#include <vector> 
#include "opencv2/core/core.hpp" 
#include "opencv2/features2d/features2d.hpp" 
#include "opencv2/highgui/highgui.hpp" 
#include "opencv2/nonfree/nonfree.hpp" 
using namespace cv; 
using namespace std; 
int main() 
{ 
Mat img1 = imread("0000.jpg", 1); 
Mat img2 = imread("0001.jpg", 1); 
// Detect keypoints in the left and right images 
FastFeatureDetector detector(50); 
vector<KeyPoint> left_keypoints,right_keypoints; 
detector.detect(img1, left_keypoints); 
detector.detect(img2, right_keypoints); 
vector<Point2f>left_points; 

for (int i = 0; i < left_keypoints.size(); ++i) 
{ 
    left_points.push_back(left_keypoints.pt); 
} 
vector<Point2f>right_points(left_points.size()); 

return 0; 
} 

我没有测试上面的代码。查看OpenCV文档here