Android OpenCV使用MatOfKeyPoint和feature2d检测

JDS*_*JDS 6 java android opencv

我在正确使用OpenCV Java库时遇到问题,以下代码崩溃:

MatOfKeyPoint keypoints = new MatOfKeyPoint();
this.myFeatures.detect(inputImage, keypoints);
Run Code Online (Sandbox Code Playgroud)

我认为关键点是这个可变对象,我将其传递给detect函数并接收回来.以后我想做:

Features2d.drawKeypoints(inputImage, keypoints, outputImage);
Run Code Online (Sandbox Code Playgroud)

我在这做错了什么?谢谢.

JDS*_*JDS 9

问题已解决 - 您不仅需要转换颜色类型,而且SURF算法不可用,至少在我的库中是这样.这是工作代码:

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);
Run Code Online (Sandbox Code Playgroud)

我希望他们能比fatal signal 11... 更好地回复错误