Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef RTABMAP_FLANN_PARAMS_H_
00031 #define RTABMAP_FLANN_PARAMS_H_
00032
00033 #include "rtflann/util/any.h"
00034 #include "rtflann/general.h"
00035 #include <iostream>
00036 #include <map>
00037
00038
00039 namespace rtflann
00040 {
00041
00042 namespace anyimpl
00043 {
00044 SMALL_POLICY(flann_algorithm_t);
00045 SMALL_POLICY(flann_centers_init_t);
00046 SMALL_POLICY(flann_log_level_t);
00047 SMALL_POLICY(flann_datatype_t);
00048 }
00049
00050
00051 typedef std::map<std::string, any> IndexParams;
00052
00053
00054 typedef enum {
00055 FLANN_False = 0,
00056 FLANN_True = 1,
00057 FLANN_Undefined
00058 } tri_type;
00059
00060
00061 struct SearchParams
00062 {
00063 SearchParams(int checks_ = 32, float eps_ = 0.0, bool sorted_ = true ) :
00064 checks(checks_), eps(eps_), sorted(sorted_)
00065 {
00066 max_neighbors = -1;
00067 use_heap = FLANN_Undefined;
00068 cores = 1;
00069 matrices_in_gpu_ram = false;
00070 }
00071
00072
00073 int checks;
00074
00075 float eps;
00076
00077 bool sorted;
00078
00079 int max_neighbors;
00080
00081 tri_type use_heap;
00082
00083 int cores;
00084
00085 bool matrices_in_gpu_ram;
00086 };
00087
00088
00089 inline bool has_param(const IndexParams& params, std::string name)
00090 {
00091 return params.find(name)!=params.end();
00092 }
00093
00094 template<typename T>
00095 T get_param(const IndexParams& params, std::string name, const T& default_value)
00096 {
00097 IndexParams::const_iterator it = params.find(name);
00098 if (it != params.end()) {
00099 return it->second.cast<T>();
00100 }
00101 else {
00102 return default_value;
00103 }
00104 }
00105
00106 template<typename T>
00107 T get_param(const IndexParams& params, std::string name)
00108 {
00109 IndexParams::const_iterator it = params.find(name);
00110 if (it != params.end()) {
00111 return it->second.cast<T>();
00112 }
00113 else {
00114 throw FLANNException(std::string("Missing parameter '")+name+std::string("' in the parameters given"));
00115 }
00116 }
00117
00118 inline void print_params(const IndexParams& params)
00119 {
00120 IndexParams::const_iterator it;
00121
00122 for(it=params.begin(); it!=params.end(); ++it) {
00123 std::cout << it->first << " : " << it->second << std::endl;
00124 }
00125 }
00126
00127 inline void print_params(const SearchParams& params)
00128 {
00129 std::cout << "checks : " << params.checks << std::endl;
00130 std::cout << "eps : " << params.eps << std::endl;
00131 std::cout << "sorted : " << params.sorted << std::endl;
00132 std::cout << "max_neighbors : " << params.max_neighbors << std::endl;
00133 }
00134
00135
00136 }
00137
00138
00139 #endif