其他分享
首页 > 其他分享> > c – OpenCV如何创建DescriptorExtractor对象

c – OpenCV如何创建DescriptorExtractor对象

作者:互联网

我正在使用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是一个抽象类,因此您无法实例化它.它只是描述符提取器的通用接口.你可以这样做:

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);

标签:opencv3-0,c,opencv
来源: https://codeday.me/bug/20190824/1707680.html