问题
Everywhere in features2D
classes I see terms query
and train
. For example matches
have trainIdx
and queryIdx
, and Matchers
have train()
method.
I know the definition of words train
and query
in English, but I can't understand the meaning of this properties or methods.
P.S. I understand, that it's very silly question, but maybe it's because English is not my native language.
回答1:
To complete sansuiso's answer, I suppose the reason for choosing these names should be that in some application we have got a set of images (training images) beforehand, for example 10 images taken inside your office. The features can be extracted and the feature descriptors can be computed for these images. And at run-time an image is given to the system to query the trained database. Hence the query image refers to this image. I really don't like the way they have named these parameters. Where you have a pair of stereo images and you want to match the features, these names don't make sense but you have to chose a convention say always call the left image the query image and the right image as the training image. I did my PhD in computer vision and some naming conventions in OpenCV seem really confusing/silly to me. So if you find these confusing or silly you're not alone.
回答2:
train
: this function builds the classifier inner state in order to make it operational. For example, think of training an SVM, or building a kd-tree from the reference data. Maybe you are confused because this step is often referred to as learning in the literature.query
is the action of finding the nearest neighbors to a set of points, and by extension it also refers to the whole set of points for which yo want a nearest neighbor. Recall that you can ask for the neighbors of 1 point, or a whole lot in the same function call (by stacking the feature points in a matrix).trainIdx
andqueryIdx
refer to the index of a pint in the reference / query set respectively, i.e. you ask the matcher for the nearest point (stored at thetrainIdx
position) to some other point (stored at thequeryIdx
position). Of course,trainIdx
is known after the function call. If your points are stored in a matrix, the index will be the line of the considered feature.
回答3:
I understand "query" and "train" in a very naive but useful way: "train": a data or image is preprocessed to get a database "query": an input data or image that will be queried in the database which we trained before. Hope it helps u as well.
来源:https://stackoverflow.com/questions/10765066/what-is-query-and-train-in-opencv-features2d