Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

[Android] Problem with FlannBasedMatcher and Orb

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?