在python2文件夹下的OpenCV
2.3.1提供的示例中,我发现了一个基于flann的match函数的实现,该函数不依赖于FlanbasedMatcher对象。
这是代码:
FLANN_INDEX_KDTREE = 1 # bug: flann enums are missingflann_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 4)def match_flann(desc1, desc2, r_threshold = 0.6): flann = cv2.flann_Index(desc2, flann_params) idx2, dist = flann.knnSearch(desc1, 2, params = {}) # bug: need to provide empty dict mask = dist[:,0] / dist[:,1] < r_threshold idx1 = np.arange(len(desc1)) pairs = np.int32( zip(idx1, idx2[:,0]) ) return pairs[mask]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)