openCV library for Renesas RZ/A

Dependents:   RZ_A2M_Mbed_samples

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?

UserRevisionLine numberNew 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-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved.
RyoheiHagimoto 0:0e0631af0305 5 * Copyright 2008-2011 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_PARAMS_H_
RyoheiHagimoto 0:0e0631af0305 31 #define OPENCV_FLANN_PARAMS_H_
RyoheiHagimoto 0:0e0631af0305 32
RyoheiHagimoto 0:0e0631af0305 33 #include "any.h"
RyoheiHagimoto 0:0e0631af0305 34 #include "general.h"
RyoheiHagimoto 0:0e0631af0305 35 #include <iostream>
RyoheiHagimoto 0:0e0631af0305 36 #include <map>
RyoheiHagimoto 0:0e0631af0305 37
RyoheiHagimoto 0:0e0631af0305 38
RyoheiHagimoto 0:0e0631af0305 39 namespace cvflann
RyoheiHagimoto 0:0e0631af0305 40 {
RyoheiHagimoto 0:0e0631af0305 41
RyoheiHagimoto 0:0e0631af0305 42 typedef std::map<cv::String, any> IndexParams;
RyoheiHagimoto 0:0e0631af0305 43
RyoheiHagimoto 0:0e0631af0305 44 struct SearchParams : public IndexParams
RyoheiHagimoto 0:0e0631af0305 45 {
RyoheiHagimoto 0:0e0631af0305 46 SearchParams(int checks = 32, float eps = 0, bool sorted = true )
RyoheiHagimoto 0:0e0631af0305 47 {
RyoheiHagimoto 0:0e0631af0305 48 // how many leafs to visit when searching for neighbours (-1 for unlimited)
RyoheiHagimoto 0:0e0631af0305 49 (*this)["checks"] = checks;
RyoheiHagimoto 0:0e0631af0305 50 // search for eps-approximate neighbours (default: 0)
RyoheiHagimoto 0:0e0631af0305 51 (*this)["eps"] = eps;
RyoheiHagimoto 0:0e0631af0305 52 // only for radius search, require neighbours sorted by distance (default: true)
RyoheiHagimoto 0:0e0631af0305 53 (*this)["sorted"] = sorted;
RyoheiHagimoto 0:0e0631af0305 54 }
RyoheiHagimoto 0:0e0631af0305 55 };
RyoheiHagimoto 0:0e0631af0305 56
RyoheiHagimoto 0:0e0631af0305 57
RyoheiHagimoto 0:0e0631af0305 58 template<typename T>
RyoheiHagimoto 0:0e0631af0305 59 T get_param(const IndexParams& params, cv::String name, const T& default_value)
RyoheiHagimoto 0:0e0631af0305 60 {
RyoheiHagimoto 0:0e0631af0305 61 IndexParams::const_iterator it = params.find(name);
RyoheiHagimoto 0:0e0631af0305 62 if (it != params.end()) {
RyoheiHagimoto 0:0e0631af0305 63 return it->second.cast<T>();
RyoheiHagimoto 0:0e0631af0305 64 }
RyoheiHagimoto 0:0e0631af0305 65 else {
RyoheiHagimoto 0:0e0631af0305 66 return default_value;
RyoheiHagimoto 0:0e0631af0305 67 }
RyoheiHagimoto 0:0e0631af0305 68 }
RyoheiHagimoto 0:0e0631af0305 69
RyoheiHagimoto 0:0e0631af0305 70 template<typename T>
RyoheiHagimoto 0:0e0631af0305 71 T get_param(const IndexParams& params, cv::String name)
RyoheiHagimoto 0:0e0631af0305 72 {
RyoheiHagimoto 0:0e0631af0305 73 IndexParams::const_iterator it = params.find(name);
RyoheiHagimoto 0:0e0631af0305 74 if (it != params.end()) {
RyoheiHagimoto 0:0e0631af0305 75 return it->second.cast<T>();
RyoheiHagimoto 0:0e0631af0305 76 }
RyoheiHagimoto 0:0e0631af0305 77 else {
RyoheiHagimoto 0:0e0631af0305 78 throw FLANNException(cv::String("Missing parameter '")+name+cv::String("' in the parameters given"));
RyoheiHagimoto 0:0e0631af0305 79 }
RyoheiHagimoto 0:0e0631af0305 80 }
RyoheiHagimoto 0:0e0631af0305 81
RyoheiHagimoto 0:0e0631af0305 82 inline void print_params(const IndexParams& params, std::ostream& stream)
RyoheiHagimoto 0:0e0631af0305 83 {
RyoheiHagimoto 0:0e0631af0305 84 IndexParams::const_iterator it;
RyoheiHagimoto 0:0e0631af0305 85
RyoheiHagimoto 0:0e0631af0305 86 for(it=params.begin(); it!=params.end(); ++it) {
RyoheiHagimoto 0:0e0631af0305 87 stream << it->first << " : " << it->second << std::endl;
RyoheiHagimoto 0:0e0631af0305 88 }
RyoheiHagimoto 0:0e0631af0305 89 }
RyoheiHagimoto 0:0e0631af0305 90
RyoheiHagimoto 0:0e0631af0305 91 inline void print_params(const IndexParams& params)
RyoheiHagimoto 0:0e0631af0305 92 {
RyoheiHagimoto 0:0e0631af0305 93 print_params(params, std::cout);
RyoheiHagimoto 0:0e0631af0305 94 }
RyoheiHagimoto 0:0e0631af0305 95
RyoheiHagimoto 0:0e0631af0305 96 }
RyoheiHagimoto 0:0e0631af0305 97
RyoheiHagimoto 0:0e0631af0305 98
RyoheiHagimoto 0:0e0631af0305 99 #endif /* OPENCV_FLANN_PARAMS_H_ */