MCPcopy Create free account
hub / github.com/creatale/node-dv / Search

Method Search

deps/tesseract/classify/kdtree.cpp:156–175  ·  view source on GitHub ↗

Locate the k_closest points to query_point_, and return their distances and data into the given buffers.

Source from the content-addressed store, hash-verified

154/// Locate the k_closest points to query_point_, and return their distances and
155/// data into the given buffers.
156void KDTreeSearch::Search(int *result_count,
157 FLOAT32 *distances,
158 void **results) {
159 if (tree_->Root.Left == NULL) {
160 *result_count = 0;
161 } else {
162 for (int i = 0; i < tree_->KeySize; i++) {
163 sb_min_[i] = tree_->KeyDesc[i].Min;
164 sb_max_[i] = tree_->KeyDesc[i].Max;
165 }
166 SearchRec(0, tree_->Root.Left);
167 int count = results_.elements_count();
168 *result_count = count;
169 for (int j = 0; j < count; j++) {
170 // TODO: why FLOAT64 here?
171 distances[j] = (FLOAT32) sqrt((FLOAT64)results_.elements()[j].key);
172 results[j] = results_.elements()[j].value;
173 }
174 }
175}
176
177/*-----------------------------------------------------------------------------
178 Public Code

Callers 1

KDNearestNeighborSearchFunction · 0.45

Calls 3

sqrtFunction · 0.85
elements_countMethod · 0.80
elementsMethod · 0.80

Tested by

no test coverage detected