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.
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
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With