Cinder

  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

include/opencv2/flann/general.h

Go to the documentation of this file.
00001 /***********************************************************************
00002  * Software License Agreement (BSD License)
00003  *
00004  * Copyright 2008-2009  Marius Muja (mariusm@cs.ubc.ca). All rights reserved.
00005  * Copyright 2008-2009  David G. Lowe (lowe@cs.ubc.ca). All rights reserved.
00006  *
00007  * THE BSD LICENSE
00008  *
00009  * Redistribution and use in source and binary forms, with or without
00010  * modification, are permitted provided that the following conditions
00011  * are met:
00012  *
00013  * 1. Redistributions of source code must retain the above copyright
00014  *    notice, this list of conditions and the following disclaimer.
00015  * 2. Redistributions in binary form must reproduce the above copyright
00016  *    notice, this list of conditions and the following disclaimer in the
00017  *    documentation and/or other materials provided with the distribution.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00020  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00021  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00022  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00023  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00024  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00025  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00026  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00027  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00028  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 #include "opencv2/flann/logger.h"
00040 
00041 namespace cvflann {
00042 
00043 #undef ARRAY_LEN
00044 #define ARRAY_LEN(a) (sizeof(a)/sizeof(a[0]))
00045 
00046 /* Nearest neighbour index algorithms */
00047 enum flann_algorithm_t {
00048     FLANN_INDEX_LINEAR = 0,
00049     FLANN_INDEX_KDTREE = 1,
00050     FLANN_INDEX_KMEANS = 2,
00051     FLANN_INDEX_COMPOSITE = 3,
00052     FLANN_INDEX_SAVED = 254,
00053     FLANN_INDEX_AUTOTUNED = 255
00054 };
00055 
00056 enum flann_centers_init_t {
00057     FLANN_CENTERS_RANDOM = 0,
00058     FLANN_CENTERS_GONZALES = 1,
00059     FLANN_CENTERS_KMEANSPP = 2
00060 };
00061 
00062 
00063 enum flann_distance_t {
00064     FLANN_DIST_EUCLIDEAN = 1,
00065     FLANN_DIST_L2 = 1,
00066     FLANN_DIST_MANHATTAN = 2,
00067     FLANN_DIST_L1 = 2,
00068     FLANN_DIST_MINKOWSKI = 3,
00069     FLANN_DIST_MAX       = 4,
00070     FLANN_DIST_HIST_INTERSECT = 5,
00071     FLANN_DIST_HELLINGER = 6,
00072     FLANN_DIST_CHI_SQUARE = 7,
00073     FLANN_DIST_CS         = 7,
00074     FLANN_DIST_KULLBACK_LEIBLER        = 8,
00075     FLANN_DIST_KL        = 8
00076 };
00077 
00078 enum flann_datatype_t {
00079     FLANN_INT8 = 0,
00080     FLANN_INT16 = 1,
00081     FLANN_INT32 = 2,
00082     FLANN_INT64 = 3,
00083     FLANN_UINT8 = 4,
00084     FLANN_UINT16 = 5,
00085     FLANN_UINT32 = 6,
00086     FLANN_UINT64 = 7,
00087     FLANN_FLOAT32 = 8,
00088     FLANN_FLOAT64 = 9
00089 };
00090 
00091 template <typename ELEM_TYPE>
00092 struct DistType
00093 {
00094     typedef ELEM_TYPE type;
00095 };
00096 
00097 template <>
00098 struct DistType<unsigned char>
00099 {
00100     typedef float type;
00101 };
00102 
00103 template <>
00104 struct DistType<int>
00105 {
00106     typedef float type;
00107 };
00108 
00109 
00110 class FLANNException : public std::runtime_error {
00111  public:
00112    FLANNException(const char* message) : std::runtime_error(message) { }
00113 
00114    FLANNException(const std::string& message) : std::runtime_error(message) { }
00115  };
00116 
00117 
00118 struct CV_EXPORTS IndexParams {
00119 protected:
00120     IndexParams(flann_algorithm_t algorithm_) : algorithm(algorithm_) {};
00121     
00122 public:
00123     virtual ~IndexParams() {}
00124     virtual flann_algorithm_t getIndexType() const { return algorithm; }
00125 
00126     virtual void print() const = 0;
00127 
00128     flann_algorithm_t algorithm;
00129 };
00130 
00131 
00132 typedef ObjectFactory<IndexParams, flann_algorithm_t> ParamsFactory;
00133 CV_EXPORTS ParamsFactory& ParamsFactory_instance();
00134 
00135 struct CV_EXPORTS SearchParams {
00136     SearchParams(int checks_ = 32) :
00137         checks(checks_) {};
00138 
00139     int checks;
00140 };
00141 
00142 } // namespace cvflann
00143 
00144 #endif
00145 
00146 #endif  /* _OPENCV_GENERAL_H_ */