How to apply my own Distance Metric in BFMatcher
I am trying to implement Jensen-Bregman LogDet Divergence which is distance measurable between two covariance matrices. My implementation is to match SURF Features on basis of JBLD.
So my question is how I can implement JBLD distance measurement for BFMatcher now I am using NORM_L2 method.
You can see the source codes and paper on JBLD on gitHub Repo.
In the early OpenCV versions ( < 2.4?) it was very easy possible. Unfortunately, with the refactoring from BruteForceMatcher to BFMatcher (whyever this was neccessary) this isn't that easy anymore in the sense that you really have to dig into OpenCV's code and add this distance by hand.
The paper looks very interesting and I am exciting to test it when you are finished.
Thanks Guanta... Is there any other way to implement covariance distance measuring in any application like tracking cars, face recognition, texture recognition etc. I just want to implement JBLD and compare it distance measurement with others like AIRM, LERM etc.
Also any Matcher like Flann that could still employ Distance measurement?
Also Guanta can you help me where to exactly change opencv code to employ this technique?
For opencv: add the norm to the others in /modules/features2d/include/opencv2/features2d.hpp and adjust modules/features2d/src/matchers.cpp (look for distType or normType). Guess actually only these two files - so maybe not too difficult at all?
For flann (the author's version not the one in OpenCV) you have to edit afaik: src/cpp/flann/define.h , src/cpp/flann/flann.cpp and src/cpp/flann/algorithms/dist.h .
If you neither want to use BFMatcher nor flann you can of course write your own bruteforce matcher - which isn't very difficult (two for loops in which you compare each descriptor with each other using JBLD) if you don't need a fast optimized version.
Good luck! And let me know if you are successful and get good results (just leave a comment here).
Thanks Guanta for such a detailed reply. Can you help me how I can match two descriptors? Which information from descriptors is useful for me to find match and corresponding keypoint which has been matched? If there is some code available or some tutorial for matcher that would be very very helpful for me to understand.
Maybe I don't get your question right, but basically a match gives you a score which is dependent on the norm of two descriptors. Example if you have a two-dimensional descriptor (=feature vector) x and another y, then using the L2 norm, their distance would be d = sqrt( (x_1-y_1)^2+(x_2-y_2) ). According to this distance / score you continue, e.g. using the best match, which would be the same as BFMatcher w. k=1 or whatever.
maybe you could add a link to the original paper ?
(github does not play nice with binary content)
http://www.ieeeexplore.net/xpl/articleDetails.jsp?tp=&arnumber=6378374&queryText%3DJensen-Bregman+LogDet+Divergence
This link works for you berak?