I am trying to extract binary features in Matlab with mexopencv. If I use ORB as a detector and extractor everything works fine. The problem is when I try to use BRIEF extractor. This is the code I am using:
detector = cv.FeatureDetector('ORB');
extractor = cv.DescriptorExtractor('BRIEF'); % if I use 'ORB' here everything works fine
img = read('my-image');
keyPoints = detector.detect(img);
descriptors = extractor.compute(img, keyPoints);
And I get the following error:
Warning: The following error was caught while executing 'cv.DescriptorExtractor' class destructor: MxArray is not a scalar
In extract_train_orb (line 5) Error using DescriptorExtractor_ Unrecognized extractor BRIEF
Error in cv.DescriptorExtractor (line 63) this.id = DescriptorExtractor_(0, 'new', extractorType, varargin{:});
Error in extract_train_orb (line 2) extractor = cv.DescriptorExtractor('BRIEF');
I do not know how to solve this issue, as the mexopencv's documentation says BRIEF is a supported extractor.
Anyone has any idea? Thanks
EDIT:
In fact, ORB is the only type currently working. 'BRIEF', 'SURF' and 'SIFT' types are getting the same error.
I am using OpenCV 3.0 and Matlab R2015b under Ubuntu 14.04.
EDIT 2:
contrib module
was not installed.
I download opencv_contrib, re-build & re-install OpenCV and finally, try to compile mexopencv contrib module by:
make MATLABDIR=/usr/local/MATLAB/R2015b contrib
Compilation fails with this error:
/tmp/mex_619067277620954_21116/BriefDescriptorExtractor_.o: In function ``mexFunction': BriefDescriptorExtractor_.cpp:(.text+0x31d8): undefined reference to `createBriefDescriptorExtractor(__gnu_cxx::__normal_iterator > >, __gnu_cxx::__normal_iterator > >)' collect2: error: ld returned 1 exit status
I solved the problem thanks to @Miki suggestions.
First, the contrib module should be installed. I re-installed OpenCV 3.0 as in this guide. Then, I run make clean
, make
and make contrib
on mexopencv directory.
Finally, I had to use
extractor = cv.DescriptorExtractor('BriefDescriptorExtractor');
instead of
extractor = cv.DescriptorExtractor('BRIEF');