Reputation: 2161
I tried FAST corner detection in Android using Opencv4Android 2.4.6. The keypoints are detected,but the view is not showing the drawn keypoints,or
Features2d.drawKeypoints
is not working,i dont know.
public Mat onCameraFrame(Mat inputFrame) {
MatOfKeyPoint points = new MatOfKeyPoint();
Mat mat = inputFrame;
FeatureDetector fast = FeatureDetector.create(FeatureDetector.FAST);
fast.detect(mat, points);
Scalar redcolor = new Scalar(255,0,0);
Mat mRgba= mat.clone();
Imgproc.cvtColor(mat, mRgba, Imgproc.COLOR_RGBA2BGRA,4);
Core.line(mRgba, new Point(100, 100), new Point(300,300), new Scalar(0, 0, 255));
Features2d.drawKeypoints(mRgba, points, mRgba, redcolor, 3);
return mRgba;
}
By logging ,i can see many keypoints are detected.but not drawn in the seen. The line i tried to draw in the view is also displayed in the view,but not keypoints.
pls help. Thanking you
Upvotes: 0
Views: 3353
Reputation: 2161
The answer i found out from this link
The problem was with Imgproc.cvtColor
.
The problem is that unfortunately drawKeypoints() can't work with RGBA Mats, it accepts 8UC3 and 8UC1 only. So if you'd like to call drawKeypoints(), you need convert the picture to RGB and then back to RGBA to display.
So i changed the code to Imgproc.cvtColor(mat, mRgba, Imgproc.COLOR_RGBA2RGB,4);
Now it is working fine,and problem of bluish color also removed
Thanks for the answers
Upvotes: 2
Reputation: 1198
I think the issue is with the DrawMatchesFlags, which is the last input in the drawKeypoints function.. Referring to the function description, you can see all the flags that are being used.. i would suggest that you use DrawMatchesFlags::DEFAULT if you don't want to go into the details..
Hope this helps.
Upvotes: 2