Ask Your Question

How to generate key points by myself

asked 2016-06-16 06:01:25 -0500

Patricia Star gravatar image

Hi, i want to compute SURF descriptors on my own key points. The problem is, currently I only have 2d image points (x,y-coordinates), but opencv's method for calculating SURF descriptors needs keypoints, which need beside the coordinates additional information like, scale, size, orientation,... (information which I do not have).

Please help -> How can I generate correct Keypoints out of my 2d image points? (Correct means, I want to have key points on exactly the coordinates of my image points).

Thanks in advance Patricia

edit retag flag offensive close merge delete


just curious, what are you trying to do with it ?

berak gravatar imageberak ( 2016-06-16 06:39:19 -0500 )edit

I'm trying to train an SVM on these descriptors. The points are image points on a persons face (e.g eyes, mouth...) and to train an svm on this descriptors to later be able to do person identification i need exactly the same points on every training image (which i have) but then also the descriptors on this points. Hope this makes it understanable :-)

Patricia Star gravatar imagePatricia Star ( 2016-06-17 03:50:28 -0500 )edit

yes, sure makes sense !

berak gravatar imageberak ( 2016-06-17 04:27:35 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-06-17 04:25:53 -0500

berak gravatar image

updated 2016-06-17 04:26:41 -0500

the "minimal" args to construct a Keypoint are x,y,size. you'll just have to invent a size, that makes sense in your image (e.g avg. distance between points).

vector<Point> pts = .... ; // from landmarks or such
vector<KeyPoint> kp; // empty
float s = 5; // ??
for (size_t i=0; i<pts.size(); i++)
    kp.push_back(pts[i].x, pts[i].y, s);

Mat descriptors;
Ptr<Feature2D> extractor = features2d::SURF::create(); // you need float features for the svm !
extractor->compute(image, kp, descriptors);
edit flag offensive delete link more


Thanks for your answer. I tried this before, but the recognition of the identity using the svm is super bad. A friend said, that he thinks it is because if I only use these three values (x,y,size) the response is default 0 and the angle is -1, that leads to keypoints which are not meaningful at all. I also tried to set the response to the same value for all keypoints and the angle to 0, but the results were really bad also :-(

Patricia Star gravatar imagePatricia Star ( 2016-06-17 04:35:08 -0500 )edit

"but the recognition of the identity using the svm is super bad."

yea, that's kinda expected ;( true, your points are not meaningful for the descriptors. you could try AKAZE instead of SURF with DESCRIPTOR_KAZE_UPRIGHT as descriptortype (since it does not expect angles) , or a "dense" grid , say 5 pix apart, instead of your landmarks, also tweaking SVM params, but in the end ...

btw, how many landmarks do you have ? (and from where?)

berak gravatar imageberak ( 2016-06-17 04:43:51 -0500 )edit

Thanks for that idea, I will give this a try. For the identification I use 11 landmarks (image points) i get them using the face-landmark-detector from dlib.

Patricia Star gravatar imagePatricia Star ( 2016-06-17 05:30:20 -0500 )edit

Question Tools



Asked: 2016-06-16 06:01:25 -0500

Seen: 482 times

Last updated: Jun 17 '16