params.h
Go to the documentation of this file.
1 /***********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved.
5  * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *************************************************************************/
28 
29 
30 #ifndef RTABMAP_FLANN_PARAMS_H_
31 #define RTABMAP_FLANN_PARAMS_H_
32 
33 #include "rtflann/util/any.h"
34 #include "rtflann/general.h"
35 #include <iostream>
36 #include <map>
37 
38 
39 namespace rtflann
40 {
41 
42 namespace anyimpl
43 {
48 }
49 
50 
51 typedef std::map<std::string, any> IndexParams;
52 
53 
54 typedef enum {
58 } tri_type;
59 
60 
62 {
63  SearchParams(int checks_ = 32, float eps_ = 0.0, bool sorted_ = true ) :
64  checks(checks_), eps(eps_), sorted(sorted_)
65  {
66  max_neighbors = -1;
67  use_heap = FLANN_Undefined;
68  cores = 1;
69  matrices_in_gpu_ram = false;
70  }
71 
72  // how many leafs to visit when searching for neighbours (-1 for unlimited)
73  int checks;
74  // search for eps-approximate neighbours (default: 0)
75  float eps;
76  // only for radius search, require neighbours sorted by distance (default: true)
77  bool sorted;
78  // maximum number of neighbors radius search should return (-1 for unlimited)
80  // use a heap to manage the result set (default: FLANN_Undefined)
81  tri_type use_heap;
82  // how many cores to assign to the search (used only if compiled with OpenMP capable compiler) (0 for auto)
83  int cores;
84  // for GPU search indicates if matrices are already in GPU ram
86 };
87 
88 
89 inline bool has_param(const IndexParams& params, std::string name)
90 {
91  return params.find(name)!=params.end();
92 }
93 
94 template<typename T>
95 T get_param(const IndexParams& params, std::string name, const T& default_value)
96 {
97  IndexParams::const_iterator it = params.find(name);
98  if (it != params.end()) {
99  return it->second.cast<T>();
100  }
101  else {
102  return default_value;
103  }
104 }
105 
106 template<typename T>
107 T get_param(const IndexParams& params, std::string name)
108 {
109  IndexParams::const_iterator it = params.find(name);
110  if (it != params.end()) {
111  return it->second.cast<T>();
112  }
113  else {
114  throw FLANNException(std::string("Missing parameter '")+name+std::string("' in the parameters given"));
115  }
116 }
117 
118 inline void print_params(const IndexParams& params)
119 {
120  IndexParams::const_iterator it;
121 
122  for(it=params.begin(); it!=params.end(); ++it) {
123  std::cout << it->first << " : " << it->second << std::endl;
124  }
125 }
126 
127 inline void print_params(const SearchParams& params)
128 {
129  std::cout << "checks : " << params.checks << std::endl;
130  std::cout << "eps : " << params.eps << std::endl;
131  std::cout << "sorted : " << params.sorted << std::endl;
132  std::cout << "max_neighbors : " << params.max_neighbors << std::endl;
133 }
134 
135 
136 }
137 
138 
139 #endif /* FLANN_PARAMS_H_ */
std::map< std::string, any > IndexParams
Definition: params.h:51
SearchParams(int checks_=32, float eps_=0.0, bool sorted_=true)
Definition: params.h:63
flann_centers_init_t
Definition: defines.h:95
T get_param(const IndexParams &params, std::string name, const T &default_value)
Definition: params.h:95
SMALL_POLICY(signed char)
tri_type
Definition: params.h:54
flann_algorithm_t
Definition: defines.h:79
tri_type use_heap
Definition: params.h:81
void print_params(const IndexParams &params)
Definition: params.h:118
bool matrices_in_gpu_ram
Definition: params.h:85
bool has_param(const IndexParams &params, std::string name)
Definition: params.h:89
flann_datatype_t
Definition: defines.h:131
flann_log_level_t
Definition: defines.h:103


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:34:59