kdtree_single_index.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. /***********************************************************************
  2. * Software License Agreement (BSD License)
  3. *
  4. * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved.
  5. * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved.
  6. *
  7. * THE BSD LICENSE
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. *
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  20. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  21. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  22. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  23. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  24. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  28. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. *************************************************************************/
  30. #ifndef OPENCV_FLANN_KDTREE_SINGLE_INDEX_H_
  31. #define OPENCV_FLANN_KDTREE_SINGLE_INDEX_H_
  32. //! @cond IGNORED
  33. #include <algorithm>
  34. #include <map>
  35. #include <cstring>
  36. #include "nn_index.h"
  37. #include "matrix.h"
  38. #include "result_set.h"
  39. #include "heap.h"
  40. #include "allocator.h"
  41. #include "random.h"
  42. #include "saving.h"
  43. namespace cvflann
  44. {
  45. struct KDTreeSingleIndexParams : public IndexParams
  46. {
  47. KDTreeSingleIndexParams(int leaf_max_size = 10, bool reorder = true, int dim = -1)
  48. {
  49. (*this)["algorithm"] = FLANN_INDEX_KDTREE_SINGLE;
  50. (*this)["leaf_max_size"] = leaf_max_size;
  51. (*this)["reorder"] = reorder;
  52. (*this)["dim"] = dim;
  53. }
  54. };
  55. /**
  56. * Randomized kd-tree index
  57. *
  58. * Contains the k-d trees and other information for indexing a set of points
  59. * for nearest-neighbor matching.
  60. */
  61. template <typename Distance>
  62. class KDTreeSingleIndex : public NNIndex<Distance>
  63. {
  64. public:
  65. typedef typename Distance::ElementType ElementType;
  66. typedef typename Distance::ResultType DistanceType;
  67. /**
  68. * KDTree constructor
  69. *
  70. * Params:
  71. * inputData = dataset with the input features
  72. * params = parameters passed to the kdtree algorithm
  73. */
  74. KDTreeSingleIndex(const Matrix<ElementType>& inputData, const IndexParams& params = KDTreeSingleIndexParams(),
  75. Distance d = Distance() ) :
  76. dataset_(inputData), index_params_(params), distance_(d)
  77. {
  78. size_ = dataset_.rows;
  79. dim_ = dataset_.cols;
  80. root_node_ = 0;
  81. int dim_param = get_param(params,"dim",-1);
  82. if (dim_param>0) dim_ = dim_param;
  83. leaf_max_size_ = get_param(params,"leaf_max_size",10);
  84. reorder_ = get_param(params,"reorder",true);
  85. // Create a permutable array of indices to the input vectors.
  86. vind_.resize(size_);
  87. for (size_t i = 0; i < size_; i++) {
  88. vind_[i] = (int)i;
  89. }
  90. }
  91. KDTreeSingleIndex(const KDTreeSingleIndex&);
  92. KDTreeSingleIndex& operator=(const KDTreeSingleIndex&);
  93. /**
  94. * Standard destructor
  95. */
  96. ~KDTreeSingleIndex()
  97. {
  98. if (reorder_) delete[] data_.data;
  99. }
  100. /**
  101. * Builds the index
  102. */
  103. void buildIndex() CV_OVERRIDE
  104. {
  105. computeBoundingBox(root_bbox_);
  106. root_node_ = divideTree(0, (int)size_, root_bbox_ ); // construct the tree
  107. if (reorder_) {
  108. delete[] data_.data;
  109. data_ = cvflann::Matrix<ElementType>(new ElementType[size_*dim_], size_, dim_);
  110. for (size_t i=0; i<size_; ++i) {
  111. for (size_t j=0; j<dim_; ++j) {
  112. data_[i][j] = dataset_[vind_[i]][j];
  113. }
  114. }
  115. }
  116. else {
  117. data_ = dataset_;
  118. }
  119. }
  120. flann_algorithm_t getType() const CV_OVERRIDE
  121. {
  122. return FLANN_INDEX_KDTREE_SINGLE;
  123. }
  124. void saveIndex(FILE* stream) CV_OVERRIDE
  125. {
  126. save_value(stream, size_);
  127. save_value(stream, dim_);
  128. save_value(stream, root_bbox_);
  129. save_value(stream, reorder_);
  130. save_value(stream, leaf_max_size_);
  131. save_value(stream, vind_);
  132. if (reorder_) {
  133. save_value(stream, data_);
  134. }
  135. save_tree(stream, root_node_);
  136. }
  137. void loadIndex(FILE* stream) CV_OVERRIDE
  138. {
  139. load_value(stream, size_);
  140. load_value(stream, dim_);
  141. load_value(stream, root_bbox_);
  142. load_value(stream, reorder_);
  143. load_value(stream, leaf_max_size_);
  144. load_value(stream, vind_);
  145. if (reorder_) {
  146. load_value(stream, data_);
  147. }
  148. else {
  149. data_ = dataset_;
  150. }
  151. load_tree(stream, root_node_);
  152. index_params_["algorithm"] = getType();
  153. index_params_["leaf_max_size"] = leaf_max_size_;
  154. index_params_["reorder"] = reorder_;
  155. }
  156. /**
  157. * Returns size of index.
  158. */
  159. size_t size() const CV_OVERRIDE
  160. {
  161. return size_;
  162. }
  163. /**
  164. * Returns the length of an index feature.
  165. */
  166. size_t veclen() const CV_OVERRIDE
  167. {
  168. return dim_;
  169. }
  170. /**
  171. * Computes the inde memory usage
  172. * Returns: memory used by the index
  173. */
  174. int usedMemory() const CV_OVERRIDE
  175. {
  176. return (int)(pool_.usedMemory+pool_.wastedMemory+dataset_.rows*sizeof(int)); // pool memory and vind array memory
  177. }
  178. /**
  179. * \brief Perform k-nearest neighbor search
  180. * \param[in] queries The query points for which to find the nearest neighbors
  181. * \param[out] indices The indices of the nearest neighbors found
  182. * \param[out] dists Distances to the nearest neighbors found
  183. * \param[in] knn Number of nearest neighbors to return
  184. * \param[in] params Search parameters
  185. */
  186. void knnSearch(const Matrix<ElementType>& queries, Matrix<int>& indices, Matrix<DistanceType>& dists, int knn, const SearchParams& params) CV_OVERRIDE
  187. {
  188. CV_Assert(queries.cols == veclen());
  189. CV_Assert(indices.rows >= queries.rows);
  190. CV_Assert(dists.rows >= queries.rows);
  191. CV_Assert(int(indices.cols) >= knn);
  192. CV_Assert(int(dists.cols) >= knn);
  193. KNNSimpleResultSet<DistanceType> resultSet(knn);
  194. for (size_t i = 0; i < queries.rows; i++) {
  195. resultSet.init(indices[i], dists[i]);
  196. findNeighbors(resultSet, queries[i], params);
  197. }
  198. }
  199. IndexParams getParameters() const CV_OVERRIDE
  200. {
  201. return index_params_;
  202. }
  203. /**
  204. * Find set of nearest neighbors to vec. Their indices are stored inside
  205. * the result object.
  206. *
  207. * Params:
  208. * result = the result object in which the indices of the nearest-neighbors are stored
  209. * vec = the vector for which to search the nearest neighbors
  210. * maxCheck = the maximum number of restarts (in a best-bin-first manner)
  211. */
  212. void findNeighbors(ResultSet<DistanceType>& result, const ElementType* vec, const SearchParams& searchParams) CV_OVERRIDE
  213. {
  214. float epsError = 1+get_param(searchParams,"eps",0.0f);
  215. std::vector<DistanceType> dists(dim_,0);
  216. DistanceType distsq = computeInitialDistances(vec, dists);
  217. searchLevel(result, vec, root_node_, distsq, dists, epsError);
  218. }
  219. private:
  220. /*--------------------- Internal Data Structures --------------------------*/
  221. struct Node
  222. {
  223. /**
  224. * Indices of points in leaf node
  225. */
  226. int left, right;
  227. /**
  228. * Dimension used for subdivision.
  229. */
  230. int divfeat;
  231. /**
  232. * The values used for subdivision.
  233. */
  234. DistanceType divlow, divhigh;
  235. /**
  236. * The child nodes.
  237. */
  238. Node* child1, * child2;
  239. };
  240. typedef Node* NodePtr;
  241. struct Interval
  242. {
  243. DistanceType low, high;
  244. };
  245. typedef std::vector<Interval> BoundingBox;
  246. typedef BranchStruct<NodePtr, DistanceType> BranchSt;
  247. typedef BranchSt* Branch;
  248. void save_tree(FILE* stream, NodePtr tree)
  249. {
  250. save_value(stream, *tree);
  251. if (tree->child1!=NULL) {
  252. save_tree(stream, tree->child1);
  253. }
  254. if (tree->child2!=NULL) {
  255. save_tree(stream, tree->child2);
  256. }
  257. }
  258. void load_tree(FILE* stream, NodePtr& tree)
  259. {
  260. tree = pool_.allocate<Node>();
  261. load_value(stream, *tree);
  262. if (tree->child1!=NULL) {
  263. load_tree(stream, tree->child1);
  264. }
  265. if (tree->child2!=NULL) {
  266. load_tree(stream, tree->child2);
  267. }
  268. }
  269. void computeBoundingBox(BoundingBox& bbox)
  270. {
  271. bbox.resize(dim_);
  272. for (size_t i=0; i<dim_; ++i) {
  273. bbox[i].low = (DistanceType)dataset_[0][i];
  274. bbox[i].high = (DistanceType)dataset_[0][i];
  275. }
  276. for (size_t k=1; k<dataset_.rows; ++k) {
  277. for (size_t i=0; i<dim_; ++i) {
  278. if (dataset_[k][i]<bbox[i].low) bbox[i].low = (DistanceType)dataset_[k][i];
  279. if (dataset_[k][i]>bbox[i].high) bbox[i].high = (DistanceType)dataset_[k][i];
  280. }
  281. }
  282. }
  283. /**
  284. * Create a tree node that subdivides the list of vecs from vind[first]
  285. * to vind[last]. The routine is called recursively on each sublist.
  286. * Place a pointer to this new tree node in the location pTree.
  287. *
  288. * Params: pTree = the new node to create
  289. * first = index of the first vector
  290. * last = index of the last vector
  291. */
  292. NodePtr divideTree(int left, int right, BoundingBox& bbox)
  293. {
  294. NodePtr node = pool_.allocate<Node>(); // allocate memory
  295. /* If too few exemplars remain, then make this a leaf node. */
  296. if ( (right-left) <= leaf_max_size_) {
  297. node->child1 = node->child2 = NULL; /* Mark as leaf node. */
  298. node->left = left;
  299. node->right = right;
  300. // compute bounding-box of leaf points
  301. for (size_t i=0; i<dim_; ++i) {
  302. bbox[i].low = (DistanceType)dataset_[vind_[left]][i];
  303. bbox[i].high = (DistanceType)dataset_[vind_[left]][i];
  304. }
  305. for (int k=left+1; k<right; ++k) {
  306. for (size_t i=0; i<dim_; ++i) {
  307. if (bbox[i].low>dataset_[vind_[k]][i]) bbox[i].low=(DistanceType)dataset_[vind_[k]][i];
  308. if (bbox[i].high<dataset_[vind_[k]][i]) bbox[i].high=(DistanceType)dataset_[vind_[k]][i];
  309. }
  310. }
  311. }
  312. else {
  313. int idx;
  314. int cutfeat;
  315. DistanceType cutval;
  316. middleSplit_(&vind_[0]+left, right-left, idx, cutfeat, cutval, bbox);
  317. node->divfeat = cutfeat;
  318. BoundingBox left_bbox(bbox);
  319. left_bbox[cutfeat].high = cutval;
  320. node->child1 = divideTree(left, left+idx, left_bbox);
  321. BoundingBox right_bbox(bbox);
  322. right_bbox[cutfeat].low = cutval;
  323. node->child2 = divideTree(left+idx, right, right_bbox);
  324. node->divlow = left_bbox[cutfeat].high;
  325. node->divhigh = right_bbox[cutfeat].low;
  326. for (size_t i=0; i<dim_; ++i) {
  327. bbox[i].low = std::min(left_bbox[i].low, right_bbox[i].low);
  328. bbox[i].high = std::max(left_bbox[i].high, right_bbox[i].high);
  329. }
  330. }
  331. return node;
  332. }
  333. void computeMinMax(int* ind, int count, int dim, ElementType& min_elem, ElementType& max_elem)
  334. {
  335. min_elem = dataset_[ind[0]][dim];
  336. max_elem = dataset_[ind[0]][dim];
  337. for (int i=1; i<count; ++i) {
  338. ElementType val = dataset_[ind[i]][dim];
  339. if (val<min_elem) min_elem = val;
  340. if (val>max_elem) max_elem = val;
  341. }
  342. }
  343. void middleSplit(int* ind, int count, int& index, int& cutfeat, DistanceType& cutval, const BoundingBox& bbox)
  344. {
  345. // find the largest span from the approximate bounding box
  346. ElementType max_span = bbox[0].high-bbox[0].low;
  347. cutfeat = 0;
  348. cutval = (bbox[0].high+bbox[0].low)/2;
  349. for (size_t i=1; i<dim_; ++i) {
  350. ElementType span = bbox[i].high-bbox[i].low;
  351. if (span>max_span) {
  352. max_span = span;
  353. cutfeat = i;
  354. cutval = (bbox[i].high+bbox[i].low)/2;
  355. }
  356. }
  357. // compute exact span on the found dimension
  358. ElementType min_elem, max_elem;
  359. computeMinMax(ind, count, cutfeat, min_elem, max_elem);
  360. cutval = (min_elem+max_elem)/2;
  361. max_span = max_elem - min_elem;
  362. // check if a dimension of a largest span exists
  363. size_t k = cutfeat;
  364. for (size_t i=0; i<dim_; ++i) {
  365. if (i==k) continue;
  366. ElementType span = bbox[i].high-bbox[i].low;
  367. if (span>max_span) {
  368. computeMinMax(ind, count, i, min_elem, max_elem);
  369. span = max_elem - min_elem;
  370. if (span>max_span) {
  371. max_span = span;
  372. cutfeat = i;
  373. cutval = (min_elem+max_elem)/2;
  374. }
  375. }
  376. }
  377. int lim1, lim2;
  378. planeSplit(ind, count, cutfeat, cutval, lim1, lim2);
  379. if (lim1>count/2) index = lim1;
  380. else if (lim2<count/2) index = lim2;
  381. else index = count/2;
  382. }
  383. void middleSplit_(int* ind, int count, int& index, int& cutfeat, DistanceType& cutval, const BoundingBox& bbox)
  384. {
  385. const float EPS=0.00001f;
  386. DistanceType max_span = bbox[0].high-bbox[0].low;
  387. for (size_t i=1; i<dim_; ++i) {
  388. DistanceType span = bbox[i].high-bbox[i].low;
  389. if (span>max_span) {
  390. max_span = span;
  391. }
  392. }
  393. DistanceType max_spread = -1;
  394. cutfeat = 0;
  395. for (size_t i=0; i<dim_; ++i) {
  396. DistanceType span = bbox[i].high-bbox[i].low;
  397. if (span>(DistanceType)((1-EPS)*max_span)) {
  398. ElementType min_elem, max_elem;
  399. computeMinMax(ind, count, (int)i, min_elem, max_elem);
  400. DistanceType spread = (DistanceType)(max_elem-min_elem);
  401. if (spread>max_spread) {
  402. cutfeat = (int)i;
  403. max_spread = spread;
  404. }
  405. }
  406. }
  407. // split in the middle
  408. DistanceType split_val = (bbox[cutfeat].low+bbox[cutfeat].high)/2;
  409. ElementType min_elem, max_elem;
  410. computeMinMax(ind, count, cutfeat, min_elem, max_elem);
  411. if (split_val<min_elem) cutval = (DistanceType)min_elem;
  412. else if (split_val>max_elem) cutval = (DistanceType)max_elem;
  413. else cutval = split_val;
  414. int lim1, lim2;
  415. planeSplit(ind, count, cutfeat, cutval, lim1, lim2);
  416. if (lim1>count/2) index = lim1;
  417. else if (lim2<count/2) index = lim2;
  418. else index = count/2;
  419. }
  420. /**
  421. * Subdivide the list of points by a plane perpendicular on axe corresponding
  422. * to the 'cutfeat' dimension at 'cutval' position.
  423. *
  424. * On return:
  425. * dataset[ind[0..lim1-1]][cutfeat]<cutval
  426. * dataset[ind[lim1..lim2-1]][cutfeat]==cutval
  427. * dataset[ind[lim2..count]][cutfeat]>cutval
  428. */
  429. void planeSplit(int* ind, int count, int cutfeat, DistanceType cutval, int& lim1, int& lim2)
  430. {
  431. /* Move vector indices for left subtree to front of list. */
  432. int left = 0;
  433. int right = count-1;
  434. for (;; ) {
  435. while (left<=right && dataset_[ind[left]][cutfeat]<cutval) ++left;
  436. while (left<=right && dataset_[ind[right]][cutfeat]>=cutval) --right;
  437. if (left>right) break;
  438. std::swap(ind[left], ind[right]); ++left; --right;
  439. }
  440. /* If either list is empty, it means that all remaining features
  441. * are identical. Split in the middle to maintain a balanced tree.
  442. */
  443. lim1 = left;
  444. right = count-1;
  445. for (;; ) {
  446. while (left<=right && dataset_[ind[left]][cutfeat]<=cutval) ++left;
  447. while (left<=right && dataset_[ind[right]][cutfeat]>cutval) --right;
  448. if (left>right) break;
  449. std::swap(ind[left], ind[right]); ++left; --right;
  450. }
  451. lim2 = left;
  452. }
  453. DistanceType computeInitialDistances(const ElementType* vec, std::vector<DistanceType>& dists)
  454. {
  455. DistanceType distsq = 0.0;
  456. for (size_t i = 0; i < dim_; ++i) {
  457. if (vec[i] < root_bbox_[i].low) {
  458. dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].low, (int)i);
  459. distsq += dists[i];
  460. }
  461. if (vec[i] > root_bbox_[i].high) {
  462. dists[i] = distance_.accum_dist(vec[i], root_bbox_[i].high, (int)i);
  463. distsq += dists[i];
  464. }
  465. }
  466. return distsq;
  467. }
  468. /**
  469. * Performs an exact search in the tree starting from a node.
  470. */
  471. void searchLevel(ResultSet<DistanceType>& result_set, const ElementType* vec, const NodePtr node, DistanceType mindistsq,
  472. std::vector<DistanceType>& dists, const float epsError)
  473. {
  474. /* If this is a leaf node, then do check and return. */
  475. if ((node->child1 == NULL)&&(node->child2 == NULL)) {
  476. DistanceType worst_dist = result_set.worstDist();
  477. if (reorder_) {
  478. for (int i=node->left; i<node->right; ++i) {
  479. DistanceType dist = distance_(vec, data_[i], dim_, worst_dist);
  480. if (dist<worst_dist) {
  481. result_set.addPoint(dist,vind_[i]);
  482. }
  483. }
  484. } else {
  485. for (int i=node->left; i<node->right; ++i) {
  486. DistanceType dist = distance_(vec, data_[vind_[i]], dim_, worst_dist);
  487. if (dist<worst_dist) {
  488. result_set.addPoint(dist,vind_[i]);
  489. }
  490. }
  491. }
  492. return;
  493. }
  494. /* Which child branch should be taken first? */
  495. int idx = node->divfeat;
  496. ElementType val = vec[idx];
  497. DistanceType diff1 = val - node->divlow;
  498. DistanceType diff2 = val - node->divhigh;
  499. NodePtr bestChild;
  500. NodePtr otherChild;
  501. DistanceType cut_dist;
  502. if ((diff1+diff2)<0) {
  503. bestChild = node->child1;
  504. otherChild = node->child2;
  505. cut_dist = distance_.accum_dist(val, node->divhigh, idx);
  506. }
  507. else {
  508. bestChild = node->child2;
  509. otherChild = node->child1;
  510. cut_dist = distance_.accum_dist( val, node->divlow, idx);
  511. }
  512. /* Call recursively to search next level down. */
  513. searchLevel(result_set, vec, bestChild, mindistsq, dists, epsError);
  514. DistanceType dst = dists[idx];
  515. mindistsq = mindistsq + cut_dist - dst;
  516. dists[idx] = cut_dist;
  517. if (mindistsq*epsError<=result_set.worstDist()) {
  518. searchLevel(result_set, vec, otherChild, mindistsq, dists, epsError);
  519. }
  520. dists[idx] = dst;
  521. }
  522. private:
  523. /**
  524. * The dataset used by this index
  525. */
  526. const Matrix<ElementType> dataset_;
  527. IndexParams index_params_;
  528. int leaf_max_size_;
  529. bool reorder_;
  530. /**
  531. * Array of indices to vectors in the dataset.
  532. */
  533. std::vector<int> vind_;
  534. Matrix<ElementType> data_;
  535. size_t size_;
  536. size_t dim_;
  537. /**
  538. * Array of k-d trees used to find neighbours.
  539. */
  540. NodePtr root_node_;
  541. BoundingBox root_bbox_;
  542. /**
  543. * Pooled memory allocator.
  544. *
  545. * Using a pooled memory allocator is more efficient
  546. * than allocating memory directly when there is a large
  547. * number small of memory allocations.
  548. */
  549. PooledAllocator pool_;
  550. Distance distance_;
  551. }; // class KDTree
  552. }
  553. //! @endcond
  554. #endif //OPENCV_FLANN_KDTREE_SINGLE_INDEX_H_