2013-05-09 71 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