Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV: Fingerprint Image and Compare Against Database

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

like image 476
Stefan Avatar asked Feb 03 '23 14:02

Stefan


2 Answers

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.

like image 180
Andrey Kamaev Avatar answered Feb 05 '23 04:02

Andrey Kamaev


Content-based image retrieval systems are still a field of active research: http://citeseerx.ist.psu.edu/search?q=content-based+image+retrieval

First you have to be clear, what constitutes similar in your context:

  1. Similar color distribution: Use something like color descriptors for subdivisions of the image, you should get some fairly satisfying results.
  2. Similar objects: Since the computer does not know, what an object is, you will not get very far, unless you have some extensive domain knowledge about the object (or few object classes). A good overview about the current state of research can be seen here (results) and soon here.

There is no "serve all needs"-algorithm for the problem you described. The more you can share about the specifics of your problem, the better answers you might get. Posting some representative images (if possible) and describing the desired outcome is also very helpful.

This would be a good question for computer-vision.stackexchange.com, if it already existed.

like image 21
bjoernz Avatar answered Feb 05 '23 04:02

bjoernz