Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android OpenCV using MatOfKeyPoint and feature2d detect

I'm having trouble using the OpenCV Java library properly, the following code is crashing:

MatOfKeyPoint keypoints = new MatOfKeyPoint();
this.myFeatures.detect(inputImage, keypoints);

I thought keypoints was this mutable object that I pass into the detect function and receive back. E.g. later I would like to do:

Features2d.drawKeypoints(inputImage, keypoints, outputImage);

What am I doing wrong here? Thanks.

like image 343
JDS Avatar asked Apr 24 '13 04:04

JDS


1 Answers

Issue resolved - not only do you have to convert color types, but the SURF algorithm isn't available, at least in the library I have. Here's the working code:

myFeatures = FeatureDetector.create(FeatureDetector.FAST);
rgb = new Mat();
outputImage = new Mat();
keypoints = new MatOfKeyPoint();

Imgproc.cvtColor(inputImage, rgb, Imgproc.COLOR_RGBA2RGB);
myFeatures.detect(rgb, keypoints);
Features2d.drawKeypoints(rgb, keypoints, rgb);
Imgproc.cvtColor(rgb, outputImage, Imgproc.COLOR_RGB2RGBA);

I wish they returned an error better than fatal signal 11...

like image 87
JDS Avatar answered Oct 13 '22 20:10

JDS