Ask Your Question
0

vlfeat's vl_ubcmatch

asked 2013-11-03 04:33:15 -0600

Ofer Bartal gravatar image

updated 2013-11-03 06:10:22 -0600

Hi, Is there any alternative in opencv for vlfeat's vl_ubcmatch for matching sifts between two images? If not, can you suggest an implementation that can be used from python?

Thanks!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2013-11-05 06:06:46 -0600

Ofer Bartal gravatar image

updated 2013-11-05 06:14:39 -0600

I ended up implementing vl_ubcmatch in python. Short and sweet :)

def find_matches(template_descriptors, current_img_descriptors, match_thresh):

    flann_params = dict(algorithm=1, trees=4)
    flann = cv2.flann_Index(current_img_descriptors, flann_params)
    idx, dist = flann.knnSearch(template_descriptors, 2, params={})
    del flann
    matches = np.c_[np.arange(len(idx)), idx[:,0]]
    pass_filter = dist[:,0]*match_thresh < dist[:,1]
    matches = matches[pass_filter]

    return matches

If you want a c++ version, this guy extracted the cpp code from vlfeat's mex code in his blog.

In the comments, he gives a link to his cpp file with the code (change the extension from txt to cpp).

edit flag offensive delete link more

Comments

for sth like this python is indeed great :)

Guanta gravatar imageGuanta ( 2013-11-05 14:35:25 -0600 )edit
3

answered 2013-11-03 07:14:54 -0600

Guanta gravatar image

Partially, you can use BFMatcher() for the first definition of vl_ubcmatch (http://www.vlfeat.org/matlab/vl_ubcmatch.html). Although not mentioned in the documentation of BFMatcher, it is also available under python (see also <your-opencv-folder>/samples/python2/find_obj.py):

>>> import cv2
>>> ? cv2.BFMatcher
Type:       builtin_function_or_method
String Form:<built-in function BFMatcher>
Docstring:  BFMatcher([, normType[, crossCheck]]) -> <BFMatcher object>


The second variant (i.e. the pruning of the results with a threshold) you would have to code yourself, this ratio-test is however pretty easy to accomplish see e.g. http://answers.opencv.org/question/4829/how-to-filter-freakbruteforcematcher-result/ .

In general, however, not each vlfeat-method is that easily adaptable with OpenCV, I wish there would be some work to fuse both great libraries...

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-11-03 04:33:15 -0600

Seen: 2,036 times

Last updated: Nov 05 '13