Ask Your Question
0

BRIEF descriptors in OpenCV 3

asked 2015-11-17 10:44:35 -0500

larry37 gravatar image

I'm having trouble migrating BRIEF feature extraction to OpenCV 3. I have followed the transition guide from http://docs.opencv.org/master/db/dfa/... to compile the contrib module and load it into opencv-master. I am including the <xfeatures2d.hpp> file and trying to get descriptors with the following code (which worked fine with OpenCV2):

cv::xfeatures2d::BriefDescriptorExtractor extractor;
extractor.create(64);

cv::KeyPoint kp = cv::KeyPoint(x, y, size);
std::vector<cv::KeyPoint> kp_vec();
kp_vec.push_back(kp);
cv::Mat descriptors;

extractor.compute(image, kp_vec, descriptors);

The program crashes on the last line inside features2d.h, with the error CV_Error(Error::StsNotImplemented, "");. Am I doing something wrong? Is the BRIEF detector missing? I could not find any examples in the openCV docs, apart from some python code that looks like the one I posted above.

edit retag flag offensive close merge delete

Comments

1

You need to include xfeatures2d.hpp, like the docs say

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-11-17 10:53:09 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
4

answered 2015-11-17 10:52:49 -0500

berak gravatar image

updated 2015-11-17 11:42:22 -0500

indeed, the interface has changed in 3.0. you can no more create an instance in auto/stack memory, but have to use the 'factory' method, which returns a Ptr<> :

 # include "opencv2/xfeaturesd2d.hpp" // don't forget to link to opencv_xfeatures2d as well..
 ...
 Ptr<BriefDescriptorExtractor> extractor = BriefDescriptorExtractor::create();
 ...
 extractor->compute(image, kp_vec, descriptors);
edit flag offensive delete link more

Comments

Thanks for the quick answer, worked perfectly.

larry37 gravatar imagelarry37 ( 2015-11-17 11:30:24 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2015-11-17 10:44:35 -0500

Seen: 994 times

Last updated: Nov 17 '15