2013-04-24 50 views
6

我正确使用OpenCV的Java库有麻烦的Android OpenCV的,下面的代码崩溃:使用MatOfKeyPoint和feature2d检测

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

我认为关键点是这个可变对象,我传递到detect功能接收回来。例如。后来我想这样做:

Features2d.drawKeypoints(inputImage, keypoints, outputImage); 

我在做什么错在这里?谢谢。

回答

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); 

我希望他们比fatal signal 11返回一个错误更好...