user1805638
user1805638

Reputation: 31

Extract BRIEF features with mexopencv

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

Upvotes: 0

Views: 1178

Answers (2)

user1805638
user1805638

Reputation: 31

I solved the problem thanks to @Miki suggestions.

  1. 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.

  2. Finally, I had to use

    extractor = cv.DescriptorExtractor('BriefDescriptorExtractor');

    instead of

    extractor = cv.DescriptorExtractor('BRIEF');

Upvotes: 1

guneykayim
guneykayim

Reputation: 5250

It might be about incompatibilities between feature detectors and descriptor extractors. For example can you try using 'SURF' for both detector and extractor?

Even if my suggestion works, I would have expect 'ORB' detector to work with 'BRIEF' extractor, since 'ORB' is just 'Oriented BRIEF'. However you should be sure about the compatibilities of detectors and feature extractors, maybe you should read papers about these techniques. For instance some extractors also produces scale or octave in addition to keypoints, and some doesn't. Similarly some descriptors expect to have scale or octave input with keypoints, and some doesn't.

Here is a primitive example; you can't charge an iPhone with Samsung charger or visa versa. Both are phones both have chargers, but they do not match.

Upvotes: 1

Related Questions