OpenCV如何创建DescriptorExtractor对象

时间:2015-10-25 16:28:36

标签: c++ opencv opencv3.0

我正在使用OpenCV C ++库,但我无法创建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 ...

1 个答案:

答案 0 :(得分: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);