Ask Your Question
0

flann : knn-search for hierarchical kmeans tree giving weird result

asked 2013-07-08 15:10:09 -0600

gaurav_kl gravatar image

I have about 130,000 SIFT descriptors. I am building a hierarchical Kmeans-index using Opencv's flann module. After this I want to quantize these 130,000 descriptors (will quantize more later). I am using flann's knnsearch method for doing this. But the result of this method is something weird. For every descriptor the nearest index it is showing is the index of the descriptor itself. However, it should be displaying the cluster-ID of the nearest cluster which will be one of the leaves of the HIK-tree.

Should I try k=2

Here is a code snippet -

int k=1;
cv::flann::KMeansIndexParams indexParams(8,4,cvflann::FLANN_CENTERS_KMEANSPP) ;
cv::flann::Index hik_tree(cluster_data, indexParams);
Mat indices,dist;
hik_tree.knnSearch(cluster_data, indices, dist, k, cv::flann::SearchParams(64));
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-07-09 04:31:33 -0600

Guanta gravatar image

Yes, use k=2 (and then first look at the first match, if it is the same index then take the second closest match), since you build your index with the same cluster_data as you are doing your knnSearch, i.e. you match the same data with each other. Thus, the first result will with very high probability be the same index since it is typically the closest one.

Btw.: I'd raise or at least try out other branching factors and number of iterations for your KMenasIndexParams, 8 and 4 seem pretty low.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-07-08 15:10:09 -0600

Seen: 985 times

Last updated: Jul 09 '13