Ask Your Question
1

Bag of Visual Words Model in Python

asked 2019-06-22 01:53:06 -0600

aditya_mangalampalli gravatar image

Hey everyone, I am currently trying to make a Bag of Words model using the classes built-in to the OpenCV feature2d framework in Python using Brisk. However the lack of documentation or clear documentation for absolute noobs like me make it hard to understand or implement. It would be helpful if anyone could share code that was already written using Brisk and the BOW classes or if anyone could explain to me what to do since I am kind of lost in a sense. Thanks for the help!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2019-06-22 02:52:55 -0600

berak gravatar image

updated 2019-06-22 03:35:53 -0600

using Brisk.implementation

this is a binary (bitstring) descriptor.

while opencv has a BoW implementation, it requires float features (kmeans is involved), like from SIFT or AKAZE(UPRIGHT).

you cannot use binary descriptors here, as there is no "mean" of 2 bitstrings, and the L2 distance does not apply.

tldr; you either have to switch descriptors, or come up with your own BoW clustering. (e.g. scikit has some clustering algos, that work nicely with binary descriptors like orb or brisk)

[edit] but ok, BoW on a napkin ;)

  1. offline: gather data. a lot. collect a dictionary of the most relevant statistical features, usually by clustering. (the goal is to find the most relevant K features)

  2. online: get "bow" features from your image(?) and use those for classification or such, not the original data.

    the most simple idea here is to collect a histogram. you compare each (surf?) feature from your img to all of the dictionary entries (the cluster centers) and increase a bin / counter for the resp. dict feature. for a dict size of 256 you have a list of 256 entries like [3,0,0,18,9,0,...] per image -- your new feature!

    ** "vlad" and "fisher vectors" are improved ideas

edit flag offensive delete link more

Comments

If I used any of the aforementioned, how would AI continue on with writing a BOW algorithm

aditya_mangalampalli gravatar imageaditya_mangalampalli ( 2019-06-22 03:02:01 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2019-06-22 01:53:06 -0600

Seen: 2,179 times

Last updated: Jun 22 '19