2013-04-24 55 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返回一個錯誤更好...