tesseract  3.05.00
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KDTreeSearch Class Reference

Public Member Functions

 KDTreeSearch (KDTREE *tree, FLOAT32 *query_point, int k_closest)
 
 ~KDTreeSearch ()
 
void Search (int *result_count, FLOAT32 *distances, void **results)
 

Detailed Description

Helper class for searching for the k closest points to query_point in tree.

Definition at line 122 of file kdtree.cpp.

Constructor & Destructor Documentation

KDTreeSearch::KDTreeSearch ( KDTREE tree,
FLOAT32 query_point,
int  k_closest 
)

Definition at line 141 of file kdtree.cpp.

141  :
142  tree_(tree),
143  query_point_(query_point) {
144  results_ = new MinK<FLOAT32, void *>(MAXSEARCH, k_closest);
145  sb_min_ = new FLOAT32[tree->KeySize];
146  sb_max_ = new FLOAT32[tree->KeySize];
147 }
float FLOAT32
Definition: host.h:111
inT16 KeySize
Definition: kdtree.h:50
#define MAXSEARCH
Definition: kdtree.cpp:38
KDTreeSearch::~KDTreeSearch ( )

Definition at line 149 of file kdtree.cpp.

149  {
150  delete results_;
151  delete[] sb_min_;
152  delete[] sb_max_;
153 }

Member Function Documentation

void KDTreeSearch::Search ( int *  result_count,
FLOAT32 distances,
void **  results 
)

Return the k nearest points' data.

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

Definition at line 157 of file kdtree.cpp.

159  {
160  if (tree_->Root.Left == NULL) {
161  *result_count = 0;
162  } else {
163  for (int i = 0; i < tree_->KeySize; i++) {
164  sb_min_[i] = tree_->KeyDesc[i].Min;
165  sb_max_[i] = tree_->KeyDesc[i].Max;
166  }
167  SearchRec(0, tree_->Root.Left);
168  int count = results_->elements_count();
169  *result_count = count;
170  for (int j = 0; j < count; j++) {
171  distances[j] = (FLOAT32) sqrt((FLOAT64)results_->elements()[j].key);
172  results[j] = results_->elements()[j].value;
173  }
174  }
175 }
int count(LIST var_list)
Definition: oldlist.cpp:108
FLOAT32 Max
Definition: ocrfeatures.h:50
struct KDNODE * Left
Definition: kdtree.h:45
KDNODE Root
Definition: kdtree.h:51
const Element * elements()
Definition: kdtree.cpp:70
float FLOAT32
Definition: host.h:111
inT16 KeySize
Definition: kdtree.h:50
PARAM_DESC KeyDesc[1]
Definition: kdtree.h:52
double FLOAT64
Definition: host.h:112
int elements_count()
Definition: kdtree.cpp:69
FLOAT32 Min
Definition: ocrfeatures.h:49

The documentation for this class was generated from the following file: