I just found one similar question here. But I just want to do a matching based on the description result from vlfeat
. The goal to detect if an image contains the object in another image, based on sift feature description extracting and matching. And I need to do it in C, not Matlab.
So how can I call vl_ubcmatch
function in C code?
This is a MEX function which is only intented to be called from MATLAB. You cannot re-use it as-is from a general purpose C program.
VLFeat C API does not provide SIFT matching functions out-of-the box. So basically you need to adapt the so-called ratio test [1] code section from this MATLAB C code section which is fairly easy (see below).
The main drawback if you want to perform robust matching is that this function does not take into account the geometry, i.e the keypoints coordinates.
What you need in addition is a geometrical consistency check which is typically performed by figuring out if there is an homography between the two images (using as input the descriptor correspondences obtained with the ratio test). This is done with an algorithm like RANSAC since the correspondences may include outliers.
But also you can speed up correspondences computation with a kd-tree.
So an alternative if you need a plain C implementation is relying on Open SIFT by Rob Hess which includes everything you need, as well as a ready-to-use command-line tool (and thus example) of matching:
See match.c.
K1
: number of descriptors in image 1,K2
: number of descriptors in image 2,ND
: descriptor dimension (= 128 for SIFT),descr1
anddescr2
: descriptors of image 1 and 2 resp. in row major order, e.gK1
lines xND
columns),thresh
: ratio test threshold value, e.g1.5
in MATLAB code.[1] see 7.1 Keypoint Matching from D. Lowe's paper.