Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: RZ_A2M_Mbed_samples
params.h
00001 /*********************************************************************** 00002 * Software License Agreement (BSD License) 00003 * 00004 * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 00005 * Copyright 2008-2011 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_FLANN_PARAMS_H_ 00031 #define OPENCV_FLANN_PARAMS_H_ 00032 00033 #include "any.h" 00034 #include "general.h" 00035 #include <iostream> 00036 #include <map> 00037 00038 00039 namespace cvflann 00040 { 00041 00042 typedef std::map<cv::String, any> IndexParams; 00043 00044 struct SearchParams : public IndexParams 00045 { 00046 SearchParams(int checks = 32, float eps = 0, bool sorted = true ) 00047 { 00048 // how many leafs to visit when searching for neighbours (-1 for unlimited) 00049 (*this)["checks"] = checks; 00050 // search for eps-approximate neighbours (default: 0) 00051 (*this)["eps"] = eps; 00052 // only for radius search, require neighbours sorted by distance (default: true) 00053 (*this)["sorted"] = sorted; 00054 } 00055 }; 00056 00057 00058 template<typename T> 00059 T get_param(const IndexParams& params, cv::String name, const T& default_value) 00060 { 00061 IndexParams::const_iterator it = params.find(name); 00062 if (it != params.end()) { 00063 return it->second.cast<T>(); 00064 } 00065 else { 00066 return default_value; 00067 } 00068 } 00069 00070 template<typename T> 00071 T get_param(const IndexParams& params, cv::String name) 00072 { 00073 IndexParams::const_iterator it = params.find(name); 00074 if (it != params.end()) { 00075 return it->second.cast<T>(); 00076 } 00077 else { 00078 throw FLANNException(cv::String("Missing parameter '")+name+cv::String("' in the parameters given")); 00079 } 00080 } 00081 00082 inline void print_params(const IndexParams& params, std::ostream& stream) 00083 { 00084 IndexParams::const_iterator it; 00085 00086 for(it=params.begin(); it!=params.end(); ++it) { 00087 stream << it->first << " : " << it->second << std::endl; 00088 } 00089 } 00090 00091 inline void print_params(const IndexParams& params) 00092 { 00093 print_params(params, std::cout); 00094 } 00095 00096 } 00097 00098 00099 #endif /* OPENCV_FLANN_PARAMS_H_ */
Generated on Tue Jul 12 2022 18:20:19 by
1.7.2