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 {
55  FLANN_False = 0,
56  FLANN_True = 1,
58 } tri_type;
59 
60 
61 struct SearchParams
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;
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)
79  int max_neighbors;
80  // use a heap to manage the result set (default: FLANN_Undefined)
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_ */
rtflann::SearchParams::SearchParams
SearchParams(int checks_=32, float eps_=0.0, bool sorted_=true)
Definition: params.h:89
general.h
rtflann::FLANN_True
@ FLANN_True
Definition: params.h:82
name
rtflann::get_param
T get_param(const IndexParams &params, std::string name, const T &default_value)
Definition: params.h:121
rtflann::FLANN_Undefined
@ FLANN_Undefined
Definition: params.h:83
rtflann::tri_type
tri_type
Definition: params.h:80
rtflann::FLANN_False
@ FLANN_False
Definition: params.h:81
rtflann::FLANNException
Definition: general.h:70
rtflann::SearchParams::matrices_in_gpu_ram
bool matrices_in_gpu_ram
Definition: params.h:111
rtflann::SearchParams::cores
int cores
Definition: params.h:109
rtflann::anyimpl::SMALL_POLICY
SMALL_POLICY(signed char)
rtflann::SearchParams::max_neighbors
int max_neighbors
Definition: params.h:105
any.h
rtflann::SearchParams::use_heap
tri_type use_heap
Definition: params.h:107
rtflann::print_params
void print_params(const IndexParams &params)
Definition: params.h:144
params
SmartProjectionParams params(gtsam::HESSIAN, gtsam::ZERO_ON_DEGENERACY)
Eigen::Triplet
rtflann::flann_algorithm_t
flann_algorithm_t
Definition: defines.h:79
rtflann::SearchParams::sorted
bool sorted
Definition: params.h:103
default_value
def default_value(type_)
rtflann::SearchParams::checks
int checks
Definition: params.h:99
rtflann::IndexParams
std::map< std::string, any > IndexParams
Definition: params.h:77
rtflann::flann_centers_init_t
flann_centers_init_t
Definition: defines.h:95
rtflann
Definition: all_indices.h:49
rtflann::flann_log_level_t
flann_log_level_t
Definition: defines.h:103
rtflann::flann_datatype_t
flann_datatype_t
Definition: defines.h:131
rtflann::has_param
bool has_param(const IndexParams &params, std::string name)
Definition: params.h:115
rtflann::SearchParams::eps
float eps
Definition: params.h:101


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:14