include/opencv2/flann/all_indices.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  * Redistribution and use in source and binary forms, with or without
00008  * modification, are permitted provided that the following conditions
00009  * are met:
00010  *
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  *************************************************************************/
00028 
00029 
00030 #ifndef _OPENCV_ALL_INDICES_H_
00031 #define _OPENCV_ALL_INDICES_H_
00032 
00033 #include "opencv2/flann/general.h"
00034 
00035 #include "opencv2/flann/nn_index.h"
00036 #include "opencv2/flann/kdtree_index.h"
00037 #include "opencv2/flann/kmeans_index.h"
00038 #include "opencv2/flann/composite_index.h"
00039 #include "opencv2/flann/linear_index.h"
00040 #include "opencv2/flann/autotuned_index.h"
00041 
00042 namespace cvflann 
00043 {
00044 
00045 template<typename T>
00046 NNIndex<T>* create_index_by_type(const Matrix<T>& dataset, const IndexParams& params)
00047 {
00048     flann_algorithm_t index_type = params.getIndexType();
00049 
00050     NNIndex<T>* nnIndex;
00051     switch (index_type) {
00052     case FLANN_INDEX_LINEAR:
00053         nnIndex = new LinearIndex<T>(dataset, (const LinearIndexParams&)params);
00054         break;
00055     case FLANN_INDEX_KDTREE:
00056         nnIndex = new KDTreeIndex<T>(dataset, (const KDTreeIndexParams&)params);
00057         break;
00058     case FLANN_INDEX_KMEANS:
00059         nnIndex = new KMeansIndex<T>(dataset, (const KMeansIndexParams&)params);
00060         break;
00061     case FLANN_INDEX_COMPOSITE:
00062         nnIndex = new CompositeIndex<T>(dataset, (const CompositeIndexParams&) params);
00063         break;
00064     case FLANN_INDEX_AUTOTUNED:
00065         nnIndex = new AutotunedIndex<T>(dataset, (const AutotunedIndexParams&) params);
00066         break;
00067     default:
00068         throw FLANNException("Unknown index type");
00069     }
00070 
00071     return nnIndex;
00072 }
00073 
00074 } //namespace cvflann
00075 
00076 #endif /* _OPENCV_ALL_INDICES_H_ */