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