Visualizing OpenCV KeyPoints

jstaker7 picture jstaker7 · Nov 3, 2013 · Viewed 17.6k times · Source

I am learning OpenCV and at the moment I am trying to understand the underlying data stored in a KeyPoint so that I can better utilize that data for an application I'm working on.

So far I have been going through these two pages:

http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_feature_detectors.html?highlight=featuredetector#FeatureDetector

http://docs.opencv.org/doc/tutorials/features2d/feature_detection/feature_detection.html

When I follow the tutorial, however, using drawKeypoints(), the points are all the same size and shape, and are drawn with a seemingly arbitrary color.

I guess I could iterate through the attributes for each key point: draw a circle, draw an arrow (for the angle), give it a color based on the response, etc. But I figured there had to be a better way.

Is there a built-in method or other approach similar to drawKeypoints() that will help me more efficiently visualize the KeyPoints of an image?

Answer

andriy picture andriy · Nov 4, 2013

Yes, there is the method to perform your task. As says in documentation

For each keypoint the circle around keypoint with keypoint size and orientation will be drawn

If you are using Java, you can simply specify the type of keypoints:

Features2d.drawKeypoints(image1, keypoints1, imageOut2,new Scalar(2,254,255),Features2d.DRAW_RICH_KEYPOINTS);

In C++:

drawKeypoints( img_1, keypoints_1, img_keypoints_1, Scalar::all(-1), DrawMatchesFlags::DRAW_RICH_KEYPOINTS );