vl_ubcmatch如何在技术上工作?

我正在阅读这里提供的vl_ubcmatch的函数源代码,我试图理解,它如何计算分数,以及它在内部如何在技术上工作。

但是,这个C代码有这些宏,奇怪的##变量喜欢,什么不是,我没有经验。 所以这里的主要问题是我在C中的无能。如果可能,有人可以告诉我, vl_ubcmatch是如何工作的? 它如何比较两个描述符?

这在比例不变关键点特殊图像特征的第7.1和7.2节中进行了解释。

该function的文档位于: http : //www.vlfeat.org/mdoc/VL_UBCMATCH.html

仅当d1和d2之间的距离远小于到d1的距离和图像2中的任何其他特征时,才使用图像1中的特征d1与图像2中的特征d2的匹配。匹配需要明显优于任何其他特征。潜在的匹配。 “重要”由传递给VL_UBCMATCH函数的阈值定义。

第7.2节引用近似最近邻搜索结构,但VL_UBCMATCH不使用此:

 for(k1 = 0 ; k1 < K1 ; ++k1, L1_pt += ND ) { \ \ PROMOTE_##MXC best = maxval ; \ PROMOTE_##MXC second_best = maxval ; \ int bestk = -1 ; \ \ /* For each point P2[k2] in the second image... */ \ for(k2 = 0 ; k2 < K2 ; ++k2, L2_pt += ND) { \ \ int bin ; \ PROMOTE_##MXC acc = 0 ; \ for(bin = 0 ; bin < ND ; ++bin) { \ PROMOTE_##MXC delta = \ ((PROMOTE_##MXC) L1_pt[bin]) - \ ((PROMOTE_##MXC) L2_pt[bin]) ; \ acc += delta*delta ; \ } \ \ /* Filter the best and second best matching point. */ \ if(acc < best) { \ second_best = best ; \ best = acc ; \ bestk = k2 ; \ } else if(acc < second_best) { \ second_best = acc ; \ } \ } \ \ L2_pt -= ND*K2 ; \ \ /* Lowe's method: accept the match only if unique. */ \ if(thresh * (float) best < (float) second_best && \ bestk != -1) { \ pairs_iterator->k1 = k1 ; \ pairs_iterator->k2 = bestk ; \ pairs_iterator->score = best ; \ pairs_iterator++ ; \ } \ } 

这是伪代码:

 matches = [] For each descriptor k1 in image 1: closest_match_distance = Infinity second_closest_match_distance = Infinity best_match = None For each descriptor k2 in image 2: distance_squared = d(k1, k2) if (distance_squared < closest_match_distance): second_closest_match_distance = closest_match_distance closest_match_distance = distance_squared best_match = k2 If (threshold * closest_match_distance < second_closest_match_distance AND best_match != None): matches.Insert((k1, best_match, closest_match_distance)) return matches