2015-10-25 84 views
2

我正在使用OpenCV C++庫,但我沒有設法創建一個DescriptorExtractor對象。 這裏是我做過什麼:OpenCV如何創建一個DescriptorExtractor對象

Mat img = imread("testOrb.jpg",CV_LOAD_IMAGE_UNCHANGED); 
std::vector<KeyPoint> kp; 
cv::Ptr<cv::ORB> detector = cv::ORB::create(); 
detector->detect(img, kp) 
//this part works  

DescriptorExtractor descriptorExtractor;  
Mat descriptors; 
descriptorExtractor.compute(img, kp, descriptors); 
//when these 3 lines are added, an error is thrown 

但我有以下錯誤信息:

OpenCV Error: The function/feature is not implemented() in detectAndCompute, file ... 

回答

6

DescriptorExtractor抽象類,所以你不能實例化。這只是描述符提取器的通用接口。你可以這樣做:

Ptr<DescriptorExtractor> descriptorExtractor = ORB::create(); 
Mat descriptors; 
descriptorExtractor->compute(img, kp, descriptors); 

注意,也存在FeatureDetector,這是關鍵點檢測的通用接口,這樣你就可以這樣做:

std::vector<KeyPoint> kp; 
Ptr<FeatureDetector> detector = ORB::create(); 
detector->detect(img, kp); 
+0

解決它,謝謝! – rocketer