Fawkes API Fawkes Development Version
rht_lines.h
1
2/***************************************************************************
3 * rht_lines.h - Header of lines shape model
4 * using Randomized Hough Transform
5 *
6 * Created: Mon Sep 26 2005 09:48:55
7 * Copyright 2005 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_RHT_LINE_H_
26#define _FIREVISION_MODELS_SHAPE_RHT_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
36namespace firevision {
37
38class ROI;
39
41{
42private:
43 std::vector<LineShape> m_Lines;
44 RhtAccumulator accumulator;
45
46public:
47 /** Creates a new RhtLinesModel instance
48 * @param max_time the maximum runtime of a single parseImage call in seconds,
49 * if you set max_iter to a small number this time may not
50 * be used completely
51 * @param max_iter the maximum number of iterations one parseImage will do,
52 * if you set max_time to a short time this number may not be reached
53 * @param nr_candidates the nr of candidates that is considered per pixel (the hole angle
54 * range is devided in this many parts/lines
55 * @param angle_from The angle to start the candidates from, given in rad, 0 is straight up
56 * @param angle_range the angle range the candidates are taken from starting at angle_from,
57 * given in rad, can be used for example to only search for horizontal lines
58 * @param r_scale This can be done to reduce the size of the hough space and to map more lines
59 * to one line
60 * @param min_votes_ratio The minimum ratio num_votes_per_line/total_num_votes that we have to
61 * have before a point in the hough space is considered to be a line,
62 * this may actually be higher if you use min_votes and set it to a higher
63 * number (set min_votes to 0 to only use min_votes_ration)
64 * @param min_votes the minimum number of votes a point in the hough space has to have before it
65 * is considered to be a line. The number may actually be higher if min_votes_ratio
66 * is set too high (set min_votes_ration to 0 to use only min_votes)
67 */
68 RhtLinesModel(float max_time = 0.005,
69 int max_iter = 1000,
70 unsigned int nr_candidates = 40,
71 float angle_from = 0,
72 float angle_range = 2 * M_PI,
73 int r_scale = 1,
74 float min_votes_ratio = 0.2f,
75 int min_votes = -1);
76 virtual ~RhtLinesModel(void);
77
78 std::string
79 getName(void) const
80 {
81 return std::string("RhtLinesModel");
82 }
83 int parseImage(unsigned char *buffer, ROI *roi);
84 int getShapeCount(void) const;
85 LineShape * getShape(int id) const;
86 LineShape * getMostLikelyShape(void) const;
87 std::vector<LineShape> *getShapes();
88
89private:
90 // The following constants are used as stopping criteria
91 float RHT_MAX_TIME;
92 int RHT_MAX_ITER;
93
94 unsigned int RHT_NR_CANDIDATES;
95 float RHT_ANGLE_INCREMENT;
96 float RHT_ANGLE_FROM;
97 float RHT_ANGLE_RANGE;
98
99 // The following constants are used for RHT accumulator precision
100 int RHT_R_SCALE;
101 //const int RHT_PHI_SCALE = 8;
102
103 int RHT_MIN_VOTES;
104 float RHT_MIN_VOTES_RATIO;
105
106 unsigned int roi_width;
107 unsigned int roi_height;
108
109 int diff_sec;
110 int diff_usec;
111
112 float f_diff_sec;
113};
114
115} // end namespace firevision
116
117#endif // FIREVISION_MODELS_SHAPE_RHT_LINES_H__
Line shape.
Definition: line.h:41
Region of interest.
Definition: roi.h:55
Hough-Transform accumulator.
Definition: ht_accum.h:125
Randomized Hough-Transform line model.
Definition: rht_lines.h:41
RhtLinesModel(float max_time=0.005, int max_iter=1000, 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 RhtLinesModel instance.
Definition: rht_lines.cpp:42
int getShapeCount(void) const
Get number of shapes.
Definition: rht_lines.cpp:167
std::vector< LineShape > * getShapes()
Get shapes.
Definition: rht_lines.cpp:204
std::string getName(void) const
Get name of shape model.
Definition: rht_lines.h:79
int parseImage(unsigned char *buffer, ROI *roi)
Parse image for given ROI.
Definition: rht_lines.cpp:76
LineShape * getShape(int id) const
Get specific shape.
Definition: rht_lines.cpp:173
virtual ~RhtLinesModel(void)
Destructor.
Definition: rht_lines.cpp:67
LineShape * getMostLikelyShape(void) const
Get best candidate.
Definition: rht_lines.cpp:183
Shape model interface.
Definition: shapemodel.h:46