OpenCV: Fingerprint Image and Compare Against Database

Stefan picture Stefan · Aug 26, 2011 · Viewed 18.5k times · Source

I have a database of images. When I take a new picture, I want to compare it against the images in this database and receive a similarity score (using OpenCV). This way I want to detect, if I have an image, which is very similar to the fresh picture.

Is it possible to create a fingerprint/hash of my database images and match new ones against it?

I'm searching for a alogrithm code snippet or technical demo and not for a commercial solution.

Best,

Stefan

Answer

Andrey Kamaev picture Andrey Kamaev · Aug 26, 2011

As Pual R has commented, this "fingerprint/hash" is usually a set of feature vectors or a set of feature descriptors. But most of feature vectors used in computer vision are usually too computationally expensive for searching against a database. So this task need a special kind of feature descriptors because such descriptors as SURF and SIFT will take too much time for searching even with various optimizations.

The only thing that OpenCV has for your task (object categorization) is implementation of Bag of visual Words (BOW).

It can compute special kind of image features and train visual words vocabulary. Next you can use this vocabulary to find similar images in your database and compute similarity score.

Here is OpenCV documentation for bag of words. Also OpenCV has a sample named bagofwords_classification.cpp. It is really big but might be helpful.