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 <vector>
29 #include <iostream>
30 #include <cmath>
31 
32 #include <fvutils/base/types.h>
33 #include <fvmodels/shape/line.h>
34 #include <fvmodels/shape/accumulators/ht_accum.h>
35 
36 namespace firevision {
37 #if 0 /* just to make Emacs auto-indent happy */
38 }
39 #endif
40 
41 class ROI;
42 
43 class HtLinesModel: public ShapeModel
44 {
45  private:
46  std::vector<LineShape> m_Lines;
47  RhtAccumulator accumulator;
48 
49  public:
50  /** Creates a new HtLinesModel instance
51  * @param nr_candidates the nr of candidates that is considered per pixel (the hole angle
52  * range is devided in this many parts/lines
53  * @param angle_from The angle to start the candidates from, given in rad, 0 is straight up
54  * @param angle_range the angle range the candidates are taken from starting at angle_from,
55  * given in rad, can be used for example to only search for horizontal lines
56  * @param r_scale This can be done to reduce the size of the hough space and to map more lines
57  * to one line
58  * @param min_votes_ratio The minimum ratio num_votes_per_line/total_num_votes that we have to
59  * have before a point in the hough space is considered to be a line,
60  * this may actually be higher if you use min_votes and set it to a higher
61  * number (set min_votes to 0 to only use min_votes_ration)
62  * @param min_votes the minimum number of votes a point in the hough space has to have before it
63  * is considered to be a line. The number may actually be higher if min_votes_ratio
64  * is set too high (set min_votes_ration to 0 to use only min_votes)
65  */
66  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);
67  virtual ~HtLinesModel(void);
68 
69  std::string getName(void) const {return std::string("RhtLinesModel");}
70  int parseImage(unsigned char* buffer, ROI *roi);
71  int getShapeCount(void) const;
72  LineShape* getShape(int id) const;
73  LineShape* getMostLikelyShape(void) const;
74  std::vector< LineShape > * getShapes();
75 
76  private:
77 
78  unsigned int RHT_NR_CANDIDATES;
79  float RHT_ANGLE_INCREMENT;
80  float RHT_ANGLE_FROM;
81  float RHT_ANGLE_RANGE;
82 
83  // The following constants are used for RHT accumulator precision
84  int RHT_R_SCALE;
85  //const int RHT_PHI_SCALE = 8;
86 
87  int RHT_MIN_VOTES;
88  float RHT_MIN_VOTES_RATIO;
89 
90  unsigned int roi_width;
91  unsigned int roi_height;
92 
93 };
94 
95 } // end namespace firevision
96 
97 #endif // __FIREVISION_MODELS_SHAPE_HT_LINES_H_
98 
Hough-Transform accumulator.
Definition: ht_accum.h:125
int getShapeCount(void) const
Get number of shapes.
Definition: ht_lines.cpp:150
virtual ~HtLinesModel(void)
Destructor.
Definition: ht_lines.cpp:69
LineShape * getShape(int id) const
Get specific shape.
Definition: ht_lines.cpp:156
Region of interest.
Definition: roi.h:58
Hough-Transform line matcher.
Definition: ht_lines.h:43
std::vector< LineShape > * getShapes()
Get all lines found.
Definition: ht_lines.cpp:189
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:53
Line shape.
Definition: line.h:40
int parseImage(unsigned char *buffer, ROI *roi)
Parse image for given ROI.
Definition: ht_lines.cpp:75
LineShape * getMostLikelyShape(void) const
Get best candidate.
Definition: ht_lines.cpp:167
Shape model interface.
Definition: shapemodel.h:49
std::string getName(void) const
Get name of shape model.
Definition: ht_lines.h:69