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

妖精的绣舞 提交于 2019-12-04 09:05:15

If I were you, I would prefer comparing the descriptors in the code, rather than in SQL. SQL isn't meant for that. 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'd rather use OpenCV¡s inbuilt FileStorage class which provides I/O onto XML and YAML files; it solves the headache of manually parsing descriptor values.

It is not optimal to use a SQL database to compare SIFT. OpenCV proposes some keypoint matchers that are more efficient. You can find an example in ./samples/cpp/matcher_simple.cpp with SURF descriptors that is easily adaptable to SIFT. Basicaly, the core is

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

As far as I remember, some matchers (e.g Flann) only works with descriptors of certain type (CV_32F).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!