FLANN with Hierarchical Clustering Index

asked 2020-05-05 09:58:11 -0500

updated 2020-05-05 10:28:54 -0500

berak gravatar image

Hi guys,

I am implementing a FLANN based matcher with ORB. For this I want to use the Hierarchical Clustering, since it can be used for binary feature matching.

My Code for initializing FLANN:

    index_params=dict(algorithm=5, branching = 32, centers_init = 0, trees = 4, leaf_max_size = 100)
    search_params = dict(checks=50)
    flann = cv2.FlannBasedMatcher(index_params, search_params)
    matches = flann.knnMatch(des_frame, des_train, k=2)

But I receive the following error:

matches = flann.knnMatch(des_frame, des_train, k=2)
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\flann\src\miniflann.cpp:315: error: (-210:Unsupported format or combination of formats) in function 'cv::flann::buildIndex_'> type=0>

The parameters are according to the FLANN manual: https://www.cs.ubc.ca/research/flann/...

Manual Page 10:

struct HierarchicalClusteringIndexParams : public IndexParams{
int branching = 32,flann_centers_init_t centers_init = FLANN_CENTERS_RANDOM,int trees = 4, 
int leaf_max_size = 100)}

I hope you can help me with this problem. thx

edit retag flag offensive close merge delete


have a look at the src -- the distance type does not match the orb features type

also, not sure, if you can set this correctly with the FlannBasedMatcher. (iirc you can with a flann::Index, but not here)

berak gravatar imageberak ( 2020-05-05 10:52:58 -0500 )edit

sidenote: please do not use magic numbers like algorithm=5

berak gravatar imageberak ( 2020-05-05 10:55:05 -0500 )edit