diff --git a/modules/flann/include/opencv2/flann/kdtree_single_index.h b/modules/flann/include/opencv2/flann/kdtree_single_index.h index e64848cb04..ce4c1c5b7e 100644 --- a/modules/flann/include/opencv2/flann/kdtree_single_index.h +++ b/modules/flann/include/opencv2/flann/kdtree_single_index.h @@ -548,11 +548,19 @@ private: /* If this is a leaf node, then do check and return. */ if ((node->child1 == NULL)&&(node->child2 == NULL)) { DistanceType worst_dist = result_set.worstDist(); - for (int i=node->left; iright; ++i) { - int index = reorder_ ? i : vind_[i]; - DistanceType dist = distance_(vec, data_[index], dim_, worst_dist); - if (distleft; iright; ++i) { + DistanceType dist = distance_(vec, data_[i], dim_, worst_dist); + if (distleft; iright; ++i) { + DistanceType dist = distance_(vec, data_[vind_[i]], dim_, worst_dist); + if (dist