I have been trying to find a way to generate similarity score ( in %) after comparing two images using SIFT in python (2.7.x) opencv (2.4.9). I was only able to find examples that draw lines between matches. How do I proceed with this.
-
to be exact i'm looking for python implementation of VL_UBCMATCH function– user93May 12, 2016 at 6:08
-
Did you find it ?– edyvedy13Jun 26, 2017 at 15:22
-
1No I couldn't find it. An example code would be really helpful– user93Jun 26, 2017 at 16:18
-
1Does stackoverflow.com/a/51728654/1021819 help?– jtlz2Sep 19, 2019 at 11:51
1 Answer
There is an opencv equivalent of vl_ubcmatch function in Matlab.
Here is the excerpt from opencv documentation.
# create BFMatcher object
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
# Match descriptors.
matches = bf.match(des1,des2)
matches = bf. match (des1, des2)
matches the two sets of descriptors and returns a list of DMatch objects. This DMatch object has four attributes: distance, trainIdx, queryIdx, imgIdx. These return values are equivalent of vl_ubcmatch function.
I hope you will find it helpful.
-
What I need is score. VL_UBCMATCH in addition to matches returns score– user93May 15, 2016 at 17:46
-
2According to VLFEAT documentation, VL_UBCMATCH returns the squared Euclidean distance to the score variable. In fact, when I try SIFT Tutorial, the score variable has distance values between the two SIFT descriptors. scores(:, 1) is 21647, and
sum((int64(da(:, 9)) - int64(db(:, 618))) .^2)
is same value , where da(:, 9) is 9th SIFT descriptor in ImageA, db(:, 618) is 618th SIFT descriptor in ImageB. Isn't this your desired output? May 19, 2016 at 16:06