提交 72868484 编写于 作者: P Pierre-Emmanuel Viel

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.
上级 73f7d091
...@@ -548,7 +548,7 @@ public: ...@@ -548,7 +548,7 @@ public:
void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE void findNeighbors(ResultSet<DistanceType>& 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 // Priority queue storing intermediate branches in the best-bin-first search
Heap<BranchSt>* heap = new Heap<BranchSt>((int)size_); Heap<BranchSt>* heap = new Heap<BranchSt>((int)size_);
...@@ -557,6 +557,8 @@ public: ...@@ -557,6 +557,8 @@ public:
int checks = 0; int checks = 0;
for (int i=0; i<trees_; ++i) { for (int i=0; i<trees_; ++i) {
findNN(root[i], result, vec, checks, maxChecks, heap, checked); findNN(root[i], result, vec, checks, maxChecks, heap, checked);
if ((checks >= maxChecks) && result.full())
break;
} }
BranchSt branch; BranchSt branch;
...@@ -748,8 +750,8 @@ private: ...@@ -748,8 +750,8 @@ private:
Heap<BranchSt>* heap, std::vector<bool>& checked) Heap<BranchSt>* heap, std::vector<bool>& checked)
{ {
if (node->childs==NULL) { if (node->childs==NULL) {
if (checks>=maxChecks) { if ((checks>=maxChecks) && result.full()) {
if (result.full()) return; return;
} }
for (int i=0; i<node->size; ++i) { for (int i=0; i<node->size; ++i) {
int index = node->indices[i]; int index = node->indices[i];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册