Ask Your Question
0

[Android] Problem with FlannBasedMatcher and Orb

asked 2013-10-13 11:19:07 -0500

Mariusz gravatar image

I am completely new to OpenCV, I have a problem with using matchers with ORB on Android device when trying to detect my object on camera screen. Here are my steps:

1) Decoding jpg file(object to detect) using ARGB_8888

2) Applying grayscale

3) Converting it to Mat:

mObjectToDetectMat = new Mat();
Utils.bitmapToMat(mObjectToDetectBmp, mObjectToDetectMat);

4) Creating Mat to pass it to JNI:

in onCameraViewStarted
Mat gray = new Mat(height, width, CvType.CV_8UC1);

in onCameraFrame(CvCameraViewFrame inputFrame)
gray = inputFrame.gray()

detectObject(gray.getNativeObjAddr(), mObjectToDetectMat.getNativeObjAddr())

5) In Jni:

Mat mGr; // reference to gray
Mat mObject; // reference to mObjectToDetectMat

OrbFeatureDetector detector(400);
std::vector<KeyPoint> keypointsObject, keypointsScene;
detector.detect(mObject, keypointsObject);
detector.detect(mGr, keypointsScene);

OrbDescriptorExtractor extractor;
Mat descriptorsObject, descriptorsScene;

extractor.compute(mObject, keypointsObject, descriptorsObject);
extractor.compute(mGr, keypointsScene, descriptorsScene);

if (descriptorsObject.type() != CV_32F) {
    descriptorsObject.convertTo(descriptorsObject, CV_32F);
}

if (descriptorsScene.type() != CV_32F) {
    descriptorsScene.convertTo(descriptorsScene, CV_32F);
}

FlannBasedMatcher matcher;
std::vector<DMatch> matches;
matcher.match(descriptorsObject, descriptorsScene, matches);

6) Application crashes on:

OpenCV Error: Unsupported format or combination of formats

What am I doing wrong?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2013-10-13 14:08:10 -0500

Moster gravatar image

For Orb you cannot use the standard flann matcher. You should use flann with lsh indexing. Like here: http://answers.opencv.org/question/12429/matching-orb-descriptors-with-flann-lsh-on-android/

Anyways, is there a reason not to use bruteforce matching which was made specifically for binary descriptors?

edit flag offensive delete link more
-1

answered 2013-11-22 09:07:00 -0500

spawnrider gravatar image

It is better to use Brute force matcher with Hamming method like this :

BFMatcher matcher(NORM_HAMMING);
edit flag offensive delete link more

Comments

Might be true for a small amout of keypoints, but not for vast amounts of those. LSH indexing will outrule the bfmatcher then

Moster gravatar imageMoster ( 2013-11-23 02:09:29 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-10-13 11:19:07 -0500

Seen: 1,508 times

Last updated: Nov 22 '13