Fawkes API  Fawkes Development Version
ht_lines.h
1 
2 /***************************************************************************
3  * ht_lines.h - Header of lines shape model
4  * using Hough Transform
5  *
6  * Created: Fri Jan 13 12:40:57 2006
7  * Copyright 2005-2006 Tim Niemueller [www.niemueller.de]
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #ifndef _FIREVISION_MODELS_SHAPE_HT_LINE_H_
26 #define _FIREVISION_MODELS_SHAPE_HT_LINE_H_
27 
28 #include <fvmodels/shape/accumulators/ht_accum.h>
29 #include <fvmodels/shape/line.h>
30 #include <fvutils/base/types.h>
31 
32 #include <cmath>
33 #include <iostream>
34 #include <vector>
35 
36 namespace firevision {
37 
38 class ROI;
39 
40 class HtLinesModel : public ShapeModel
41 {
42 private:
43  std::vector<LineShape> m_Lines;
44  RhtAccumulator accumulator;
45 
46 public:
47  /** Creates a new HtLinesModel instance
48  * @param nr_candidates the nr of candidates that is considered per pixel (the hole angle
49  * range is devided in this many parts/lines
50  * @param angle_from The angle to start the candidates from, given in rad, 0 is straight up
51  * @param angle_range the angle range the candidates are taken from starting at angle_from,
52  * given in rad, can be used for example to only search for horizontal lines
53  * @param r_scale This can be done to reduce the size of the hough space and to map more lines
54  * to one line
55  * @param min_votes_ratio The minimum ratio num_votes_per_line/total_num_votes that we have to
56  * have before a point in the hough space is considered to be a line,
57  * this may actually be higher if you use min_votes and set it to a higher
58  * number (set min_votes to 0 to only use min_votes_ration)
59  * @param min_votes the minimum number of votes a point in the hough space has to have before it
60  * is considered to be a line. The number may actually be higher if min_votes_ratio
61  * is set too high (set min_votes_ration to 0 to use only min_votes)
62  */
63  HtLinesModel(unsigned int nr_candidates = 40,
64  float angle_from = 0,
65  float angle_range = 2 * M_PI,
66  int r_scale = 1,
67  float min_votes_ratio = 0.2f,
68  int min_votes = -1);
69  virtual ~HtLinesModel(void);
70 
71  std::string
72  getName(void) const
73  {
74  return std::string("RhtLinesModel");
75  }
76  int parseImage(unsigned char *buffer, ROI *roi);
77  int getShapeCount(void) const;
78  LineShape * getShape(int id) const;
79  LineShape * getMostLikelyShape(void) const;
80  std::vector<LineShape> *getShapes();
81 
82 private:
83  unsigned int RHT_NR_CANDIDATES;
84  float RHT_ANGLE_INCREMENT;
85  float RHT_ANGLE_FROM;
86  float RHT_ANGLE_RANGE;
87 
88  // The following constants are used for RHT accumulator precision
89  int RHT_R_SCALE;
90  //const int RHT_PHI_SCALE = 8;
91 
92  int RHT_MIN_VOTES;
93  float RHT_MIN_VOTES_RATIO;
94 
95  unsigned int roi_width;
96  unsigned int roi_height;
97 };
98 
99 } // end namespace firevision
100 
101 #endif // FIREVISION_MODELS_SHAPE_HT_LINES_H__
Hough-Transform accumulator.
Definition: ht_accum.h:124
int getShapeCount(void) const
Get number of shapes.
Definition: ht_lines.cpp:146
virtual ~HtLinesModel(void)
Destructor.
Definition: ht_lines.cpp:71
LineShape * getShape(int id) const
Get specific shape.
Definition: ht_lines.cpp:152
Region of interest.
Definition: roi.h:54
Hough-Transform line matcher.
Definition: ht_lines.h:40
std::vector< LineShape > * getShapes()
Get all lines found.
Definition: ht_lines.cpp:183
HtLinesModel(unsigned int nr_candidates=40, float angle_from=0, float angle_range=2 *M_PI, int r_scale=1, float min_votes_ratio=0.2f, int min_votes=-1)
Creates a new HtLinesModel instance.
Definition: ht_lines.cpp:51
Line shape.
Definition: line.h:40
int parseImage(unsigned char *buffer, ROI *roi)
Parse image for given ROI.
Definition: ht_lines.cpp:77
LineShape * getMostLikelyShape(void) const
Get best candidate.
Definition: ht_lines.cpp:162
Shape model interface.
Definition: shapemodel.h:45
std::string getName(void) const
Get name of shape model.
Definition: ht_lines.h:72