Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is `query` and `train` in openCV features2D

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.

like image 731
Larry Cinnabar Avatar asked May 26 '12 09:05

Larry Cinnabar


3 Answers

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.

like image 173
fireant Avatar answered Nov 02 '22 14:11

fireant


  • 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).

  • trainIdxand queryIdx 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 the trainIdx position) to some other point (stored at the queryIdxposition). Of course, trainIdxis known after the function call. If your points are stored in a matrix, the index will be the line of the considered feature.

like image 12
sansuiso Avatar answered Nov 02 '22 14:11

sansuiso


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.

like image 3
thunderY Avatar answered Nov 02 '22 13:11

thunderY