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
00031 #ifndef _OPENCV_GENERAL_H_
00032 #define _OPENCV_GENERAL_H_
00033
00034 #ifdef __cplusplus
00035
00036 #include <stdexcept>
00037 #include <cassert>
00038 #include "opencv2/flann/object_factory.h"
00039
00040 namespace cvflann {
00041
00042 #undef ARRAY_LEN
00043 #define ARRAY_LEN(a) (sizeof(a)/sizeof(a[0]))
00044
00045
00046 enum flann_algorithm_t {
00047 LINEAR = 0,
00048 KDTREE = 1,
00049 KMEANS = 2,
00050 COMPOSITE = 3,
00051 SAVED = 254,
00052 AUTOTUNED = 255
00053 };
00054
00055 enum flann_centers_init_t {
00056 CENTERS_RANDOM = 0,
00057 CENTERS_GONZALES = 1,
00058 CENTERS_KMEANSPP = 2
00059 };
00060
00061 enum flann_log_level_t {
00062 LOG_NONE = 0,
00063 LOG_FATAL = 1,
00064 LOG_ERROR = 2,
00065 LOG_WARN = 3,
00066 LOG_INFO = 4
00067 };
00068
00069 enum flann_distance_t {
00070 EUCLIDEAN = 1,
00071 MANHATTAN = 2,
00072 MINKOWSKI = 3,
00073 MAX_DIST = 4,
00074 HIK = 5,
00075 HELLINGER = 6,
00076 CS = 7,
00077 CHI_SQUARE = 7,
00078 KL = 8,
00079 KULLBACK_LEIBLER = 8
00080 };
00081
00082 enum flann_datatype_t {
00083 INT8 = 0,
00084 INT16 = 1,
00085 INT32 = 2,
00086 INT64 = 3,
00087 UINT8 = 4,
00088 UINT16 = 5,
00089 UINT32 = 6,
00090 UINT64 = 7,
00091 FLOAT32 = 8,
00092 FLOAT64 = 9
00093 };
00094
00095 template <typename ELEM_TYPE>
00096 struct DistType
00097 {
00098 typedef ELEM_TYPE type;
00099 };
00100
00101 template <>
00102 struct DistType<unsigned char>
00103 {
00104 typedef float type;
00105 };
00106
00107 template <>
00108 struct DistType<int>
00109 {
00110 typedef float type;
00111 };
00112
00113
00114 class FLANNException : public std::runtime_error {
00115 public:
00116 FLANNException(const char* message) : std::runtime_error(message) { }
00117
00118 FLANNException(const std::string& message) : std::runtime_error(message) { }
00119 };
00120
00121
00122 struct CV_EXPORTS IndexParams {
00123 protected:
00124 IndexParams(flann_algorithm_t algorithm_) : algorithm(algorithm_) {};
00125
00126 public:
00127 virtual ~IndexParams() {}
00128 virtual flann_algorithm_t getIndexType() const = 0;
00129
00130 virtual void print() const = 0;
00131
00132 flann_algorithm_t algorithm;
00133 };
00134
00135
00136 typedef ObjectFactory<IndexParams, flann_algorithm_t> ParamsFactory;
00137 CV_EXPORTS ParamsFactory& ParamsFactory_instance();
00138
00139 struct CV_EXPORTS SearchParams {
00140 SearchParams(int checks_ = 32) :
00141 checks(checks_) {};
00142
00143 int checks;
00144 };
00145
00146 }
00147
00148 #endif
00149
00150 #endif