opencv on mbed

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers miniflann.hpp Source File

miniflann.hpp

00001 /*M///////////////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
00004 //
00005 //  By downloading, copying, installing or using the software you agree to this license.
00006 //  If you do not agree to this license, do not download, install,
00007 //  copy or use the software.
00008 //
00009 //
00010 //                           License Agreement
00011 //                For Open Source Computer Vision Library
00012 //
00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
00015 // Third party copyrights are property of their respective owners.
00016 //
00017 // Redistribution and use in source and binary forms, with or without modification,
00018 // are permitted provided that the following conditions are met:
00019 //
00020 //   * Redistribution's of source code must retain the above copyright notice,
00021 //     this list of conditions and the following disclaimer.
00022 //
00023 //   * Redistribution's in binary form must reproduce the above copyright notice,
00024 //     this list of conditions and the following disclaimer in the documentation
00025 //     and/or other materials provided with the distribution.
00026 //
00027 //   * The name of the copyright holders may not be used to endorse or promote products
00028 //     derived from this software without specific prior written permission.
00029 //
00030 // This software is provided by the copyright holders and contributors "as is" and
00031 // any express or implied warranties, including, but not limited to, the implied
00032 // warranties of merchantability and fitness for a particular purpose are disclaimed.
00033 // In no event shall the Intel Corporation or contributors be liable for any direct,
00034 // indirect, incidental, special, exemplary, or consequential damages
00035 // (including, but not limited to, procurement of substitute goods or services;
00036 // loss of use, data, or profits; or business interruption) however caused
00037 // and on any theory of liability, whether in contract, strict liability,
00038 // or tort (including negligence or otherwise) arising in any way out of
00039 // the use of this software, even if advised of the possibility of such damage.
00040 //
00041 //M*/
00042 
00043 #ifndef _OPENCV_MINIFLANN_HPP_
00044 #define _OPENCV_MINIFLANN_HPP_
00045 
00046 #include "opencv2/core.hpp"
00047 #include "opencv2/flann/defines.h"
00048 
00049 namespace cv
00050 {
00051 
00052 namespace flann
00053 {
00054 
00055 struct CV_EXPORTS IndexParams
00056 {
00057     IndexParams();
00058     ~IndexParams();
00059 
00060     String getString(const String& key, const String& defaultVal=String()) const;
00061     int getInt(const String& key, int defaultVal=-1) const;
00062     double getDouble(const String& key, double defaultVal=-1) const;
00063 
00064     void setString(const String& key, const String& value);
00065     void setInt(const String& key, int value);
00066     void setDouble(const String& key, double value);
00067     void setFloat(const String& key, float value);
00068     void setBool(const String& key, bool value);
00069     void setAlgorithm(int value);
00070 
00071     void getAll(std::vector<String>& names,
00072                 std::vector<int>& types,
00073                 std::vector<String>& strValues,
00074                 std::vector<double>& numValues) const;
00075 
00076     void* params;
00077 };
00078 
00079 struct CV_EXPORTS KDTreeIndexParams : public IndexParams
00080 {
00081     KDTreeIndexParams(int trees=4);
00082 };
00083 
00084 struct CV_EXPORTS LinearIndexParams : public IndexParams
00085 {
00086     LinearIndexParams();
00087 };
00088 
00089 struct CV_EXPORTS CompositeIndexParams : public IndexParams
00090 {
00091     CompositeIndexParams(int trees = 4, int branching = 32, int iterations = 11,
00092                          cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, float cb_index = 0.2f );
00093 };
00094 
00095 struct CV_EXPORTS AutotunedIndexParams : public IndexParams
00096 {
00097     AutotunedIndexParams(float target_precision = 0.8f, float build_weight = 0.01f,
00098                          float memory_weight = 0, float sample_fraction = 0.1f);
00099 };
00100 
00101 struct CV_EXPORTS HierarchicalClusteringIndexParams : public IndexParams
00102 {
00103     HierarchicalClusteringIndexParams(int branching = 32,
00104                       cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, int trees = 4, int leaf_size = 100 );
00105 };
00106 
00107 struct CV_EXPORTS KMeansIndexParams : public IndexParams
00108 {
00109     KMeansIndexParams(int branching = 32, int iterations = 11,
00110                       cvflann::flann_centers_init_t centers_init = cvflann::FLANN_CENTERS_RANDOM, float cb_index = 0.2f );
00111 };
00112 
00113 struct CV_EXPORTS LshIndexParams : public IndexParams
00114 {
00115     LshIndexParams(int table_number, int key_size, int multi_probe_level);
00116 };
00117 
00118 struct CV_EXPORTS SavedIndexParams : public IndexParams
00119 {
00120     SavedIndexParams(const String& filename);
00121 };
00122 
00123 struct CV_EXPORTS SearchParams : public IndexParams
00124 {
00125     SearchParams( int checks = 32, float eps = 0, bool sorted = true );
00126 };
00127 
00128 class CV_EXPORTS_W Index
00129 {
00130 public:
00131     CV_WRAP Index();
00132     CV_WRAP Index(InputArray features, const IndexParams& params, cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2);
00133     virtual ~Index();
00134 
00135     CV_WRAP virtual void build(InputArray features, const IndexParams& params, cvflann::flann_distance_t distType=cvflann::FLANN_DIST_L2);
00136     CV_WRAP virtual void knnSearch(InputArray query, OutputArray indices,
00137                    OutputArray dists, int knn, const SearchParams& params=SearchParams());
00138 
00139     CV_WRAP virtual int radiusSearch(InputArray query, OutputArray indices,
00140                              OutputArray dists, double radius, int maxResults,
00141                              const SearchParams& params=SearchParams());
00142 
00143     CV_WRAP virtual void save(const String& filename) const;
00144     CV_WRAP virtual bool load(InputArray features, const String& filename);
00145     CV_WRAP virtual void release();
00146     CV_WRAP cvflann::flann_distance_t getDistance() const;
00147     CV_WRAP cvflann::flann_algorithm_t getAlgorithm() const;
00148 
00149 protected:
00150     cvflann::flann_distance_t distType;
00151     cvflann::flann_algorithm_t algo;
00152     int featureType;
00153     void* index;
00154 };
00155 
00156 } } // namespace cv::flann
00157 
00158 #endif
00159