I am trying to detect feature points using SURF and descriptor extractor using BRIEF.
cv::Ptr<Feature2D> detector = xfeatures2d::SurfFeatureDetector::create(400);
Mat descriptors_img1, descriptors_img2;
//-- Step 2: Calculate descriptors (feature vectors)
detector->detect(img1, kp1);
detector->detect(img2, kp2);
cv::Ptr<DescriptorExtractor> extractor = xfeatures2d::BriefDescriptorExtractor::create(400);
extractor->compute(img1, kp1, descriptors_img1 );
extractor->compute(img2, kp2, descriptors_img2 );
But I am getting error
OpenCV Error: Bad argument (bytes must be 16, 32, or 64) in BriefDescriptorExtractorImpl, file /home/user/opencv_contrib-3.2.0/modules/xfeatures2d/src/brief.cpp, line 185
terminate called after throwing an instance of 'cv::Exception'
what(): /home/user/opencv_contrib-3.2.0/modules/xfeatures2d/src/brief.cpp:185: error: (-5) bytes must be 16, 32, or 64 in function BriefDescriptorExtractorImpl
can anyone explain about this error and also how to solve it. I am using OpenCV3.2
BriefDescriptorExtractor(int bytes=32,bool use_orientation = false)
The first argument should be of bytes. So from your code, remove the argument 400 and try. The first argument should be of 2^ and not 400. change your code from
cv::Ptr<DescriptorExtractor> extractor = xfeatures2d::BriefDescriptorExtractor::create(400);
to
cv::Ptr<DescriptorExtractor> extractor = xfeatures2d::BriefDescriptorExtractor::create();