EstervQrCode 1.1.1
Library for qr code manipulation
all_indices.h
1 /***********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved.
5  * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in the
15  * documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *************************************************************************/
28 
29 
30 #ifndef OPENCV_FLANN_ALL_INDICES_H_
31 #define OPENCV_FLANN_ALL_INDICES_H_
32 
34 
35 #include "general.h"
36 
37 #include "nn_index.h"
38 #include "kdtree_index.h"
39 #include "kdtree_single_index.h"
40 #include "kmeans_index.h"
41 #include "composite_index.h"
42 #include "linear_index.h"
43 #include "hierarchical_clustering_index.h"
44 #include "lsh_index.h"
45 #include "autotuned_index.h"
46 
47 
48 namespace cvflann
49 {
50 
51 template<typename KDTreeCapability, typename VectorSpace, typename Distance>
52 struct index_creator
53 {
54  static NNIndex<Distance>* create(const Matrix<typename Distance::ElementType>& dataset, const IndexParams& params, const Distance& distance)
55  {
56  flann_algorithm_t index_type = get_param<flann_algorithm_t>(params, "algorithm");
57 
58  NNIndex<Distance>* nnIndex;
59  switch (index_type) {
60  case FLANN_INDEX_LINEAR:
61  nnIndex = new LinearIndex<Distance>(dataset, params, distance);
62  break;
63  case FLANN_INDEX_KDTREE_SINGLE:
64  nnIndex = new KDTreeSingleIndex<Distance>(dataset, params, distance);
65  break;
66  case FLANN_INDEX_KDTREE:
67  nnIndex = new KDTreeIndex<Distance>(dataset, params, distance);
68  break;
69  case FLANN_INDEX_KMEANS:
70  nnIndex = new KMeansIndex<Distance>(dataset, params, distance);
71  break;
72  case FLANN_INDEX_COMPOSITE:
73  nnIndex = new CompositeIndex<Distance>(dataset, params, distance);
74  break;
75  case FLANN_INDEX_AUTOTUNED:
76  nnIndex = new AutotunedIndex<Distance>(dataset, params, distance);
77  break;
78  case FLANN_INDEX_HIERARCHICAL:
79  nnIndex = new HierarchicalClusteringIndex<Distance>(dataset, params, distance);
80  break;
81  case FLANN_INDEX_LSH:
82  nnIndex = new LshIndex<Distance>(dataset, params, distance);
83  break;
84  default:
85  FLANN_THROW(cv::Error::StsBadArg, "Unknown index type");
86  }
87 
88  return nnIndex;
89  }
90 };
91 
92 template<typename VectorSpace, typename Distance>
93 struct index_creator<False,VectorSpace,Distance>
94 {
95  static NNIndex<Distance>* create(const Matrix<typename Distance::ElementType>& dataset, const IndexParams& params, const Distance& distance)
96  {
97  flann_algorithm_t index_type = get_param<flann_algorithm_t>(params, "algorithm");
98 
99  NNIndex<Distance>* nnIndex;
100  switch (index_type) {
101  case FLANN_INDEX_LINEAR:
102  nnIndex = new LinearIndex<Distance>(dataset, params, distance);
103  break;
104  case FLANN_INDEX_KMEANS:
105  nnIndex = new KMeansIndex<Distance>(dataset, params, distance);
106  break;
107  case FLANN_INDEX_HIERARCHICAL:
108  nnIndex = new HierarchicalClusteringIndex<Distance>(dataset, params, distance);
109  break;
110  case FLANN_INDEX_LSH:
111  nnIndex = new LshIndex<Distance>(dataset, params, distance);
112  break;
113  default:
114  FLANN_THROW(cv::Error::StsBadArg, "Unknown index type");
115  }
116 
117  return nnIndex;
118  }
119 };
120 
121 template<typename Distance>
122 struct index_creator<False,False,Distance>
123 {
124  static NNIndex<Distance>* create(const Matrix<typename Distance::ElementType>& dataset, const IndexParams& params, const Distance& distance)
125  {
126  flann_algorithm_t index_type = get_param<flann_algorithm_t>(params, "algorithm");
127 
128  NNIndex<Distance>* nnIndex;
129  switch (index_type) {
130  case FLANN_INDEX_LINEAR:
131  nnIndex = new LinearIndex<Distance>(dataset, params, distance);
132  break;
133  case FLANN_INDEX_KMEANS:
134  nnIndex = new KMeansIndex<Distance>(dataset, params, distance);
135  break;
136  case FLANN_INDEX_HIERARCHICAL:
137  nnIndex = new HierarchicalClusteringIndex<Distance>(dataset, params, distance);
138  break;
139  case FLANN_INDEX_LSH:
140  nnIndex = new LshIndex<Distance>(dataset, params, distance);
141  break;
142  default:
143  FLANN_THROW(cv::Error::StsBadArg, "Unknown index type");
144  }
145 
146  return nnIndex;
147  }
148 };
149 
150 template<typename Distance>
151 NNIndex<Distance>* create_index_by_type(const Matrix<typename Distance::ElementType>& dataset, const IndexParams& params, const Distance& distance)
152 {
153  return index_creator<typename Distance::is_kdtree_distance,
154  typename Distance::is_vector_space_distance,
155  Distance>::create(dataset, params,distance);
156 }
157 
158 }
159 
161 
162 #endif /* OPENCV_FLANN_ALL_INDICES_H_ */
@ StsBadArg
function arg/param is bad
Definition: base.hpp:74
Definition: flann.hpp:60