Ask Your Question
4

How to get the coordinate from "class KeyPoint"?

asked 2012-09-17 09:34:30 -0600

arnold780114 gravatar image

updated 2012-09-17 12:05:26 -0600

Kirill Kornyakov gravatar image

The following is my code.

std::vector<KeyPoint> keypoints_object, keypoints_scene;
detector.detect( img_object, keypoints_object );
detector.detect( img_scene, keypoints_scene );

I'm trying to get the coordinate in the keypoints_object & keypoints_scene to store in another variable. Does someone know how to do it? (PS:My opencv version is 2.4.2)

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2012-09-18 04:58:23 -0600

Rui Marques gravatar image

And if you have matched object keypoints with scene keypoints you do it like this to get the matches coordinates:

match_in_object = keypoints_object[ match[i].trainIdx ].pt;

match_in_scene = keypoints_scene[ match[i].queryIdx ].pt;
edit flag offensive delete link more
8

answered 2012-09-18 01:21:17 -0600

Michael Burdinov gravatar image

updated 2013-03-25 08:59:24 -0600

berak gravatar image

One of the fields of KeyPoint object is 'pt', which is the coordinate of this key point. Its type is Point2f. So you can access the coordinates like this:

Point2f p = keypoints_object[i].pt;

Or like this

float x = keypoints_object[i].pt.x;
float y = keypoints_object[i].pt.y;

See here for more information about fields of KeyPoint.

edit flag offensive delete link more

Comments

This gives me a segfault. why?

theo-b gravatar imagetheo-b ( 2015-05-14 12:17:12 -0600 )edit

^^ maybe ask a new question, that also shows your usage ?

berak gravatar imageberak ( 2015-05-14 13:09:30 -0600 )edit

Question Tools

Stats

Asked: 2012-09-17 09:34:30 -0600

Seen: 23,430 times

Last updated: Mar 25 '13