Commit 29eda007 authored by oulenz's avatar oulenz Committed by GitHub

Fix `FLANN_INDEX_KDTREE`, add `FLANN_INDEX_LSH` initialisation

Add initialisations to make clear what values actually have to be passed.

Moreover, in accordance with https://github.com/opencv/opencv/blob/383559c2285baaf3df8cf0088072d104451a30ce/modules/flann/include/opencv2/flann/defines.h#L68, I believe `FLANN_INDEX_KDTREE` was being initialised wrongly in the code examples, 1 should be correct, whereas 0 is `FLANN_INDEX_LINEAR`.
parent ee9c0f5f
...@@ -148,11 +148,13 @@ its related parameters etc. First one is IndexParams. For various algorithms, th ...@@ -148,11 +148,13 @@ its related parameters etc. First one is IndexParams. For various algorithms, th
passed is explained in FLANN docs. As a summary, for algorithms like SIFT, SURF etc. you can pass passed is explained in FLANN docs. As a summary, for algorithms like SIFT, SURF etc. you can pass
following: following:
@code{.py} @code{.py}
FLANN_INDEX_KDTREE = 1
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5) index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
@endcode @endcode
While using ORB, you can pass the following. The commented values are recommended as per the docs, While using ORB, you can pass the following. The commented values are recommended as per the docs,
but it didn't provide required results in some cases. Other values worked fine.: but it didn't provide required results in some cases. Other values worked fine.:
@code{.py} @code{.py}
FLANN_INDEX_LSH = 6
index_params= dict(algorithm = FLANN_INDEX_LSH, index_params= dict(algorithm = FLANN_INDEX_LSH,
table_number = 6, # 12 table_number = 6, # 12
key_size = 12, # 20 key_size = 12, # 20
...@@ -179,7 +181,7 @@ kp1, des1 = sift.detectAndCompute(img1,None) ...@@ -179,7 +181,7 @@ kp1, des1 = sift.detectAndCompute(img1,None)
kp2, des2 = sift.detectAndCompute(img2,None) kp2, des2 = sift.detectAndCompute(img2,None)
# FLANN parameters # FLANN parameters
FLANN_INDEX_KDTREE = 0 FLANN_INDEX_KDTREE = 1
index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5) index_params = dict(algorithm = FLANN_INDEX_KDTREE, trees = 5)
search_params = dict(checks=50) # or pass empty dictionary search_params = dict(checks=50) # or pass empty dictionary
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment