1. 程式人生 > >opencv-api FlannBasedMatcher

opencv-api FlannBasedMatcher

Fast Library forApproximate Nearest Neighbors

1.建立物件

<FlannBasedMatcher object> = cv.FlannBasedMatcher( [, indexParams[, searchParams]] )

indexParams

引數 描述
FLANN_INDEX_LINEAR 線性暴力(brute-force)搜尋
FLANN_INDEX_KDTREE 隨機kd樹,平行搜尋。預設trees=4
FLANN_INDEX_KMEANS 層次k均值樹。預設branching=32,iterations=11,centers_init = CENTERS_RANDOM, cb_index =0.2
FLANN_INDEX_COMPOSITE 隨機kd樹和層次k均值樹來構建索引。預設trees =4,branching =32,iterations =11,centers_init = CENTERS_RANDOM,cb_index =0.2
FLANN_INDEX_KDTREE_SINGLE
FLANN_INDEX_HIERARCHICAL
FLANN_INDEX_LSH multi-probe LSH方法
FLANN_INDEX_SAVED
FLANN_INDEX_AUTOTUNED
LINEAR
KDTREE
KMEANS
COMPOSITE
KDTREE_SINGLE
SAVED
AUTOTUNED 自動選取,以提供最好的效能

searchParams
SearchParams (int checks=32, float eps=0, bool sorted=true)

引數 描述
checks 預設32
eps 預設為0
sorted 預設True

2.匹配方法

FlannBasedMatcher物件繼承了cv::DescriptorMatcher.

matches	=	cv.DescriptorMatcher.knnMatch(	queryDescriptors, trainDescriptors, k[, mask[, compactResult]]	)
matches	=	cv.DescriptorMatcher.knnMatch(	queryDescriptors, k[, masks[, compactResult]]	)
引數 描述
queryDescriptors 原圖
trainDescriptors 搜尋的圖片
matches 匹配的結果
k Count of best matches found per each query descriptor or less if a query descriptor has less than k possible matches in total.設定閾值,越高精度越高,匹配的數量越少
masks Set of masks.
compactResult Parameter used when the mask (or masks) is not empty.

matches

引數 描述
distance
imgIdx 訓練圖片的索引
queryIdx query descriptor index
trainIdx train descriptor index