Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV how to create a DescriptorExtractor object

I am using OpenCV C++ library but I don't manage to create a DescriptorExtractor object. Here is what I did :

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

But I have the following error message :

OpenCV Error: The function/feature is not implemented () in detectAndCompute, file ...
like image 444
rocketer Avatar asked Feb 08 '23 17:02

rocketer


1 Answers

DescriptorExtractor is an abstract class, so you can't instantiate it. It's just a common interface for descriptor extractors. You can do like:

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

Note that exists also FeatureDetector, that is the common interface for detecting keypoints, so you can do:

std::vector<KeyPoint> kp;
Ptr<FeatureDetector> detector = ORB::create();
detector->detect(img, kp);
like image 95
Miki Avatar answered Feb 16 '23 02:02

Miki