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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef _OPENCV_MINIFLANN_HPP_
00044 #define _OPENCV_MINIFLANN_HPP_
00045
00046 #ifdef __cplusplus
00047
00048 #include "opencv2/core/core.hpp"
00049 #include "opencv2/flann/defines.h"
00050
00051 namespace cv
00052 {
00053
00054 namespace flann
00055 {
00056
00057 struct CV_EXPORTS IndexParams
00058 {
00059 IndexParams();
00060 ~IndexParams();
00061
00062 std::string getString(const std::string& key, const std::string& defaultVal=std::string()) const;
00063 int getInt(const std::string& key, int defaultVal=-1) const;
00064 double getDouble(const std::string& key, double defaultVal=-1) const;
00065
00066 void setString(const std::string& key, const std::string& value);
00067 void setInt(const std::string& key, int value);
00068 void setDouble(const std::string& key, double value);
00069 void setFloat(const std::string& key, float value);
00070 void setBool(const std::string& key, bool value);
00071 void setAlgorithm(int value);
00072
00073 void getAll(std::vector<std::string>& names,
00074 std::vector<int>& types,
00075 std::vector<std::string>& strValues,
00076 std::vector<double>& numValues) const;
00077
00078 void* params;
00079 };
00080
00081 struct CV_EXPORTS KDTreeIndexParams : public IndexParams
00082 {
00083 KDTreeIndexParams(int trees=4);
00084 };
00085
00086 struct CV_EXPORTS LinearIndexParams : public IndexParams
00087 {
00088 LinearIndexParams();
00089 };
00090
00091 struct CV_EXPORTS CompositeIndexParams : public IndexParams
00092 {
00093 CompositeIndexParams(int trees = 4, int branching = 32, int iterations = 11,
00094 cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, float cb_index = 0.2 );
00095 };
00096
00097 struct CV_EXPORTS AutotunedIndexParams : public IndexParams
00098 {
00099 AutotunedIndexParams(float target_precision = 0.8, float build_weight = 0.01,
00100 float memory_weight = 0, float sample_fraction = 0.1);
00101 };
00102
00103 struct CV_EXPORTS HierarchicalClusteringIndexParams : public IndexParams
00104 {
00105 HierarchicalClusteringIndexParams(int branching = 32,
00106 cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, int trees = 4, int leaf_size = 100 );
00107 };
00108
00109 struct CV_EXPORTS KMeansIndexParams : public IndexParams
00110 {
00111 KMeansIndexParams(int branching = 32, int iterations = 11,
00112 cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, float cb_index = 0.2 );
00113 };
00114
00115 struct CV_EXPORTS LshIndexParams : public IndexParams
00116 {
00117 LshIndexParams(int table_number, int key_size, int multi_probe_level);
00118 };
00119
00120 struct CV_EXPORTS SavedIndexParams : public IndexParams
00121 {
00122 SavedIndexParams(const std::string& filename);
00123 };
00124
00125 struct CV_EXPORTS SearchParams : public IndexParams
00126 {
00127 SearchParams( int checks = 32, float eps = 0, bool sorted = true );
00128 };
00129
00130 class CV_EXPORTS_W Index
00131 {
00132 public:
00133 CV_WRAP Index();
00134 CV_WRAP Index(InputArray features, const IndexParams& params, cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2);
00135 virtual ~Index();
00136
00137 CV_WRAP virtual void build(InputArray features, const IndexParams& params, cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2);
00138 CV_WRAP virtual void knnSearch(InputArray query, OutputArray indices,
00139 OutputArray dists, int knn, const SearchParams& params=SearchParams());
00140
00141 CV_WRAP virtual int radiusSearch(InputArray query, OutputArray indices,
00142 OutputArray dists, double radius, int maxResults,
00143 const SearchParams& params=SearchParams());
00144
00145 CV_WRAP virtual void save(const std::string& filename) const;
00146 CV_WRAP virtual bool load(InputArray features, const std::string& filename);
00147 CV_WRAP virtual void release();
00148 CV_WRAP cvflann::flann_distance_t getDistance() const;
00149 CV_WRAP cvflann::flann_algorithm_t getAlgorithm() const;
00150
00151 protected:
00152 cvflann::flann_distance_t distType;
00153 cvflann::flann_algorithm_t algo;
00154 int featureType;
00155 void* index;
00156 };
00157
00158 } }
00159
00160 #endif // __cplusplus
00161
00162 #endif