我正在使用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 ...
最佳答案
DescriptorExtractor
是一个抽象类,因此您无法实例化它。它只是描述符提取器的通用接口(interface)。您可以像这样:
Ptr<DescriptorExtractor> descriptorExtractor = ORB::create();
Mat descriptors;
descriptorExtractor->compute(img, kp, descriptors);
请注意,还存在
FeatureDetector
,它是检测关键点的常用接口(interface),因此您可以执行以下操作:std::vector<KeyPoint> kp;
Ptr<FeatureDetector> detector = ORB::create();
detector->detect(img, kp);