From 728684840cf7e2b3e65b08945d22e0356b2f533d Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Viel Date: Thu, 18 Jun 2020 16:30:29 +0200 Subject: [PATCH] Fix trees parsing behavior in hierarchical_clustering_index: Before, when maxCheck was reached in the first descent of a tree, time was still wasted parsing the next trees till their best leaves whose points were not used at all. --- .../include/opencv2/flann/hierarchical_clustering_index.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h b/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h index d830bc6a00..2937509924 100644 --- a/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h +++ b/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h @@ -548,7 +548,7 @@ public: void findNeighbors(ResultSet& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE { - int maxChecks = get_param(searchParams,"checks",32); + const int maxChecks = get_param(searchParams,"checks",32); // Priority queue storing intermediate branches in the best-bin-first search Heap* heap = new Heap((int)size_); @@ -557,6 +557,8 @@ public: int checks = 0; for (int i=0; i= maxChecks) && result.full()) + break; } BranchSt branch; @@ -748,8 +750,8 @@ private: Heap* heap, std::vector& checked) { if (node->childs==NULL) { - if (checks>=maxChecks) { - if (result.full()) return; + if ((checks>=maxChecks) && result.full()) { + return; } for (int i=0; isize; ++i) { int index = node->indices[i];