0
我試圖顯示一個圖像與檢測到的關鍵點。在我的代碼中,我得到了關鍵點的列表,我的屏幕上無法顯示圖像。我認爲我的問題是將圖像轉換爲來自MAT的位圖。 我做錯了什麼?在Android上顯示圖像的關鍵點 - OpenCV
這裏是我的代碼:
Mat teste = new Mat();
Mat mRgba = teste.clone();
Mat outputMat = new Mat();
BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
Bitmap bitmap = drawable.getBitmap();
Utils.bitmapToMat(bitmap, teste);
MatOfKeyPoint myKeyPoints = new MatOfKeyPoint();
FeatureDetector orb = FeatureDetector.create(FeatureDetector.ORB);
orb.detect(teste, myKeyPoints);
List<KeyPoint> referenceKeypointsList =
myKeyPoints.toList();
Imgproc.cvtColor(teste, mRgba, Imgproc.COLOR_RGBA2RGB,4);
Features2d.drawKeypoints(mRgba, myKeyPoints, mRgba, new Scalar(2,254,255), Features2d.DRAW_RICH_KEYPOINTS);
Imgproc.cvtColor(mRgba, outputMat, Imgproc.COLOR_RGB2RGBA);
Utils.matToBitmap(outputMat, bitmap);
imageView.setImageBitmap(bitmap);
BTW引用:mRgba應該叫mRgb因爲根據您的使用cvtColor它不包含alpha通道。我不確定Imgproc.COLOR_RGBA2RGB,4導致什麼 - 可能刪除4,因爲你想要一個RGB圖像,即三個通道 – PhilLab 2014-11-22 15:35:28
4它就像Features2d.DRAW_RICH_KEYPOINTS。 – NatsuDragonEye 2014-11-22 16:19:53
變量的名稱是一個錯誤。我的結果就像一個白色的屏幕,就是它。我不明白爲什麼,我喜歡這種方式:[按照鏈接](http://stackoverflow.com/questions/20537280/keypoint-list-to-matofkeypoint?rq=1) – NatsuDragonEye 2014-11-22 16:21:00