C ++ / SIFT / SQL - If there is a way to effectively compare the SIFT descriptor of an image with the SIFT descriptor in an SQL database?

I would like to find a way to compare the SIFT descriptor of the image (query) with the descriptors in the SQL database, which contains many descriptors of different images.

In fact, my ultimate goal is to make an application that allows you to compare one image with a large number of images in the database (not on my device), but in the SQL database.

The first thing I thought of was to stock each SQL database descriptor and compare each descriptor with a different Brute Force method or FlanneBased method. The problem is that it will take a long time in the SQL database to calculate the correspondence due to the “math” after matching (for example, the Euclidean distance is sqrt (a² + b² + ...)), and this is impossible for such a comparison in a huge database.

For example, the SIFT descriptor contains 128 numbers, if I'm not mistaken, so imagine a time comparing each number of each descriptor together.

If there is another way to do this? I know in a SQL database, queries are effective when you use something like "SELECT a FROM b WHERE ..."

So I wonder if there is a way to use SIFT descriptors efficiently? For example, I thought about “encrypting” the descriptors in the form of a large chain of strings, and each chain would be unique, and therefore I could compare them together, but I do not know if this is a good solution.

I already read this post: Comparing the SIFT capabilities stored in the mysql database , but that didn't help me. Thanks.

+4
c ++ mysql sql-server opencv sift
source share
2 answers

If I were you, I would rather compare the descriptors in the code, rather than in SQL. SQL is not intended for this. I would do the following: -

1. Pre-load N descriptors from SQL onto memory. 2. Compare distances to query descriptor, descriptor by descriptor. 3. If distance<threshold, push to possiblematches. 4. When you reach N/2 descriptors, push the next N. 5. Compare all matches, choose the best one or the best D descriptors, as per your requirement. 

However, for this I would prefer to use the built-in FileStorage class from OpenCV, which provides I / O to XML and YAML files; he solves a headache by manually analyzing the descriptor values.

+1
source share

Cannot use SQL database to compare SIFT. OpenCV offers some key compliance points that are more effective. You can find an example in ./samples/cpp/matcher_simple.cpp with SURF descriptors that easily adapt to SIFT. Basically, core

 BFMatcher matcher(NORM_L2); vector<DMatch> matches; matcher.match(descriptors1, descriptors2, matches); 

As far as I remember, some matches (for example, Flann) work only with descriptors of a certain type (CV_32F).

0
source share

All Articles