简体   繁体   中英

Opencv Surf and FlannIndex to find image in images database

I'm new to opencv and using EMGU as wrapper in C#. I'm trying to get the best similar image for a query image from images database.

I followed up the example as show here to do the work.

it uses SURF detector to detect image features and then it combines all database images descriptors in one Super descriptors matrix for matching.

Then it uses the Flann Index to find the nearest neighbors of the query image.

The problem is that the distance matrix "dists" always contains "0" values.

 flannIndex.KnnSearch(queryDescriptors, indices, dists, 2, 24); 

Please the following code in your project:

if (img.IndexStart <= indices[i, 0] && img.IndexEnd >= indices[i, 0])
                    //if (img.IndexStart <= i && img.IndexEnd >= i)
                    {
                        img.Similarity++;
                        break;
                    }

Change to:

    if (img.IndexStart <= indices[i, 1] && img.IndexEnd >= indices[i, 1])
                    //if (img.IndexStart <= i && img.IndexEnd >= i)
                    {
                        img.Similarity++;
                        break;
                    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM