In bag of visual words, how to pass descriptors instead of keypoints?

asked 2016-07-15 01:55:35 -0500

lovaj gravatar image

I'm implementing the Bag of Features model through OpenCV.

My workflow is the following:

  1. Compute SIFT keypoints & descriptors for each image in the dataset
  2. Using the descriptors and cv::BOWKMeansTrainer, compute the k centroids using k-means algorithm via cv::BOWKMeansTrainer.cluster()
  3. Using cv::BOWImgDescriptorExtractor compute the word of each image img from the dataset (same for a query) through compute(img,keyPoints,word) (we can use keyPoints that we computed during step 1.).

The problem is in point 3: I think that compute compute again the descriptors of img. This is terribly inefficient, we already computed the needed descriptors in step 1.!

How can I call compute passing the already computed descriptors?

Notice that I didn't check the implementation of compute, but I'm quite sure (from my understanding of the BoF model) that interally is going to compute the descriptors.

edit retag flag offensive close merge delete

Comments

you only worry about this, because the training set for your dictionary (steps 1. and 2. above) overlaps with your svm(or whatever you use) training data, which is usually not the case.

berak gravatar imageberak ( 2016-07-15 02:03:50 -0500 )edit

Really? For image-retrieval system, this is absolutely the case! :D And plenty of other applications too, I guess.

lovaj gravatar imagelovaj ( 2016-07-15 02:19:00 -0500 )edit

what about this compute() overload then ?

berak gravatar imageberak ( 2016-07-16 03:21:48 -0500 )edit