what is the meaning and use of class member class_id of class cv::KeyPoint in opencv?
Asked Answered
C

2

6

In reference manual of OpenCV 2.4.3 KeyPoint::class_id is described as "object id that can be used to clustered keypoints by an object they belong to".

Due to lack of my adequate knowledge about 'keypoint' I can't understand whats the purpose of class_id.

My another question is, by using feature detector, descriptor and matcher we can detect matching keypoints of a query object in a training image. But how can segment out the query object in the training image. Can we use grabcut or watershed algorithm? if yes, how?

Answer of either question will be helpful.

Thanks in advance...

Crine answered 31/7, 2013 at 21:15 Comment(0)
G
6

The class_id member field can be used, in practice, to store any information that you find useful for each keypoint. As the documentation says, you can store, for example, the id of a detected object.

For example, you have an image, extract keypoints from it (e.g. with SURF), run some object detector with these features, and the result is that each input feature contains now in class_id the id of the corresponding object, or -1 if they are attached to no object. I don't actually know if this field is filled by some OpenCV function or it is just for your use.

Regarding your second question, matching features may not be enough to segment out your object, because features can be located inside the object, so that you don't get any information about the outline. This is a good starting point, though, if you have more information about the object. For example, if you know that your object is planar (a poster on the wall), you can use the feature matches to compute a homography between the input and the training images. This would give you an outline. Or, for example, a large collection of close matched features may be an indication of the presence of an object. From that, you may try some other color segmentation, edge matching, etc.

Giorgione answered 31/7, 2013 at 23:55 Comment(3)
@ChoronoTrigger thanks for your helpful ans. but class_id is not still clear to me. what did you mean by 'run some object detector with these features' ?Crine
I mean that any algorithm can use that field for information purposes. For example, I write an object detector algorithm in c++, and I tell you that, if you give me a collection of keypoints, I'll modify their class_id field to tell you which object each keypoint belongs to.Giorgione
as far as I know, KAZE and AKAZE detectors use the class_id field of keypoints to store some information. This is retrieved when computing KAZE/AKAZE descriptors. Most (all?) other detectors set it to -1Rectangle
H
-1

I have found some short description about the class_id of a keypoint.

OpenCV says that:

class_id is object ID, that can be used to cluster keypoints by an object they belong to.

Here is the link.

Hope this will be somehow helpful.

Herschelherself answered 30/11, 2015 at 21:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.