Image Component Library (ICL)
RDPApproximation.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLCV/src/ICLCV/RDPApproximation.h **
10 ** Module : ICLCV **
11 ** Authors: Sergius Gaulik **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/Point.h>
35 #include <ICLUtils/Point32f.h>
36 #include <ICLCore/Img.h>
37 #include <ICLCore/Types.h>
38 #include <vector>
39 
40 namespace icl{
41  namespace cv{
42 
44 
65 
69  };
70 
71  public:
73  RDPApproximation(float epsilon = 0.1f, int max_corners = 0, int search_iters = 3) :
74  epsilon(epsilon), max_corners(max_corners), search_iters(search_iters) {};
75 
77 
80  const std::vector<utils::Point32f> &approximate(const std::vector<utils::Point> &poly, bool polygon = true);
81  const std::vector<utils::Point32f> &approximate(const std::vector<utils::Point32f> &poly, bool polygon = true);
82  const std::vector<utils::Point32f> &approximate(const utils::Point *begin, const utils::Point *end, const int size, bool polygon = true);
83 
85  void drawAllPoints(core::ImgBase *img, const icl64f &value);
86 
88  inline const std::vector<utils::Point32f> &getLastApproximation() const {
89  return approximation;
90  }
91 
92  inline void setEpsilon(float value){ epsilon = value; }
93  inline void setMaxCorners(float value){ max_corners = value; }
94  inline void setSearchIterations(float value){ search_iters = value; }
95  inline float getEpsilon() const { return epsilon; }
96  inline float getMaxCorners() const { return max_corners; }
97  inline float getSearchIterations() const { return search_iters; }
98 
99  private:
101  float epsilon;
104 
106  void approximateCurve(const ChainPoint *first, const ChainPoint *last);
107 
109 
112  int approximateCurveWithCap(const ChainPoint *first, const ChainPoint *last, int cap);
113 
115  void approximatePolygon(const ChainPoint *cps, const int size, bool polygon);
116 
118  void approximateWithCap(const ChainPoint *cps, const int size, bool polygon);
119 
121  std::vector<utils::Point32f> approximation;
122  };
123  } // namespace cv
124 }
ICLQt_API void polygon(ImgQ &image, const std::vector< utils::Point > &corners)
draws a polygon (constructed out of linestrips
undocument this line if you encounter any issues!
Definition: Any.h:37
void setEpsilon(float value)
Definition: RDPApproximation.h:92
const std::vector< utils::Point32f > & getLastApproximation() const
returns the last approximation result
Definition: RDPApproximation.h:88
std::vector< utils::Point32f > approximation
result list
Definition: RDPApproximation.h:121
#define ICLCV_API
Definition: CompatMacros.h:177
float epsilon
parameters
Definition: RDPApproximation.h:101
int max_corners
Definition: RDPApproximation.h:102
Ipp64f icl64f
64Bit floating point type for the ICL
Definition: BasicTypes.h:52
Definition: RDPApproximation.h:66
RDPApproximation(float epsilon=0.1f, int max_corners=0, int search_iters=3)
default constructor with given arguments
Definition: RDPApproximation.h:73
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
Ramer-Douglas-Peucker algorithm.
Definition: RDPApproximation.h:64
int search_iters
Definition: RDPApproximation.h:103
Point class of the ICL used e.g. for the Images ROI offset.
Definition: Point.h:58
float getMaxCorners() const
Definition: RDPApproximation.h:96
void setSearchIterations(float value)
Definition: RDPApproximation.h:94
void setMaxCorners(float value)
Definition: RDPApproximation.h:93
float getEpsilon() const
Definition: RDPApproximation.h:95
ChainPoint * next
Definition: RDPApproximation.h:68
ChainPoint * prev
Definition: RDPApproximation.h:67
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131
float getSearchIterations() const
Definition: RDPApproximation.h:97