Ask Your Question
0

classification with bag of visual word in python

asked 2018-05-22 05:45:31 -0600

jojo13 gravatar image

updated 2018-05-22 06:21:22 -0600

berak gravatar image

I'm trying to classify different dog races using opencv and visual bag of word technique. I'm new in the field and I wondering 3 questions about the approach.

  1. I have seen code example where the BOWtrainer is used with the matcher. Does it means the matcher help to find the "good keypoints/descriptors" so only the good ones will be used for the clustering. I cannot find any reference (tutorial?) on the subject and how it works. I don't know if it's common practice or not.

  2. I'd like to compare the quality of the different detector/descriptor techniques BEFORE using them in the clustering . Can i use PCA on the descriptor to see if they have a good separative power? the problem I encountered is that the number of keypoints varies with each picture, should i flatten the descriptor for each image so they got same dimension and they can be compared with PCA?

  3. I would like to use several techniques for the bag of visual word like ORB, SIFT SURF etc... should i perform K-means clustering for each descriptor, make histogram for each image and the finally concatenate each new features in a big feature vector so i can use a classifier on them? I have read that Kmeans clustering is not supposed to be good with binary descriptors. That approach could allow a different clustering adapted to the descriptor kind and then mixe every one of them in the end?

Thank you for your help

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2018-05-22 09:25:14 -0600

berak gravatar image

updated 2018-05-22 10:08:32 -0600

here's a tutorial

  1. idk, if this is a good idea (i've never seen that). the clustering is to find the most statistically relevant features, not those who "matched best" in your train data set (which might be irrelevant for a classification).

  2. that's probably not possible or feasible. your final classification will tell, if your data processing was good or bad, and again, you cannot classify unclustered features properly (dimension problem). also, PCA does no "comparison". i don't see, how that would be useful.

  3. while fusing several features for machine-learning is quite common, rather "multi-voc", clustering on different datasets (using the same kind of descriptor) is used. if one of your descriptor types works better than the others, stick with that. (else probably you'll degrade the ml result) also see "the curse of dimensionality"

  4. you can use binary descriptors, like ORB, BRISK, BRIEF, etc. but you need a different algorithm for clustering them, since comparing those with L2 distance makes no sense. you'll need to find something, that uses HAMMING distance here (maybe from scikit), or write your own, like db_scan.

  5. there have been improvements made on the BoW idea, like VLAD or fisher-vectors. look it up.

  6. it's nice, that you want to try it like this, but most likely training a cnn from scratch (or, using transfer-learning with an existing model, and your data) will be more successful.

edit flag offensive delete link more

Comments

Thank you for your answers berak the work I'm doing is part of a project I have to do, first "classical method" i.e. "manual" feature finding and a second part will be CNN.

  1. what I mean is this code for instance http://answers.opencv.org/question/82... . the matcher is used in the bowdescriptorextractor for Kmean clustering this is something I don't understand.

  2. in the project they ask for dimension reduction for assessing which type of detector could work best. I've tried it on color feature ( which got all the same size ) and I was able to see that each dimension contribute the same in terms of variance. Therefore the feature detector should not be good for classification, a priori

jojo13 gravatar imagejojo13 ( 2018-05-22 16:26:41 -0600 )edit
  1. This is part of a project which ask for combining features (?) it's true I see in examples found on the web, only one type of detector associated to a classification through BOW

  2. about using binary features and Kmeans I’ve read a lot that this approach was wrong but I have seen lot of code which seem to work with the famous float conversion! I'm bit puzzled by this.

  3. will do

  4. I will try CNN just after.

jojo13 gravatar imagejojo13 ( 2018-05-22 16:31:14 -0600 )edit

but I have seen lot of code which seem to work with the famous float conversion!

cargo cult. a classic.

the matcher is used in the bowdescriptorextractor

yes. but not for the kmeans clustering

I've tried it on color feature

features2d descriptors onlywork on grayscale images

berak gravatar imageberak ( 2018-05-22 20:08:14 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-05-22 05:45:31 -0600

Seen: 1,158 times

Last updated: May 22 '18