Ask Your Question

FAST detection OpenCV for Android gives blue/red screen

asked 2013-03-21 19:51:24 -0500

MysticBE gravatar image

updated 2013-03-21 20:56:35 -0500

I want to detect all the FAST corner with my application, and use the following code:

public Mat onCameraFrame(Mat inputFrame) { MatOfKeyPoint points = new MatOfKeyPoint();

  FeatureDetector fast = FeatureDetector.create(FeatureDetector.FAST);
  fast.detect(inputFrame, points);

  Scalar redcolor = new Scalar(255,0,0);
  Imgproc.cvtColor(inputFrame, mRgba, Imgproc.COLOR_RGBA2BGRA,4);
  Features2d.drawKeypoints(mRgba, points, mRgba, redcolor, 3);

    return mRgba;


It doesn't return errors, but it also doesn't show the FAST points. Instead I get a blue/red screen. I have no idea what is wrong in the code that this happend. image description

UPDATE: I got the points visible on the screen, but the colors are still messed up. A new problem is that i get like 200+ FAST points, can i put a limit on this? At higher resolution images (the one below is 320*240) there are so much points that is causes lag in my FPS. How do I limit this?

image description

edit retag flag offensive close merge delete


How did you manage to show FAST points,i am not able to do so. i tried same code posted here.pls help

sonupt4u gravatar imagesonupt4u ( 2013-11-05 12:14:12 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-03-22 00:53:36 -0500

Return value of onCameraFrame call back must be RGBA(!), not BGRA image. You call cvtColor with COLOR_RGBA2BGRA conversion and swap color channels. Exclude this and colors will be ok. Most OpenCV algorithms expect BGR images, but in your case drawKeypoints will work with RGBA too. The only thing you need to do is to swap colors in redcolor vector accordingly.

edit flag offensive delete link more


Thanks, this worked. The only thing I can't seem to find is how to put a limit on the keypoints. Any ideas on this? Should an if loop with a counter do the trick, or is there something better?

MysticBE gravatar imageMysticBE ( 2013-03-25 16:16:59 -0500 )edit

Question Tools


Asked: 2013-03-21 19:51:24 -0500

Seen: 1,340 times

Last updated: Mar 22 '13