Fawkes API  Fawkes Development Version
ht_accum.h
1 
2 /***************************************************************************
3  * ht_accum.h - Accumulator class for HoughTransform
4  *
5  * Created: Tue Jun 28 00:00:00 2005
6  * Copyright 2005 Hu Yuxiao <Yuxiao.Hu@rwth-aachen.de>
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __FIREVISION_MODELS_SHAPE_ACCUMULATORS_HT_ACCUM_H_
25 #define __FIREVISION_MODELS_SHAPE_ACCUMULATORS_HT_ACCUM_H_
26 
27 #include <stdlib.h>
28 #include <ostream>
29 #include <vector>
30 
31 namespace firevision {
32 #if 0 /* just to make Emacs auto-indent happy */
33 }
34 #endif
35 
37 {
38  public:
39  RhtAccNode();
40  virtual ~RhtAccNode();
41  virtual void clear(int ignore);
42 
43  protected:
44  /** left */
46  /** right */
48  /** used for recycling */
50 };
51 
52 class RhtRNode : public RhtAccNode
53 {
54  public:
55  RhtRNode(int r);
56  void clear(void);
57  int insert(int r);
58  void dump(std::ostream&, int x, int y);
59  void clear(int r);
60  void getNodes(std::vector< std::vector< int > > *rv, int min_votes, int x, int y);
61 
62  static RhtRNode* generate(int r);
63  static void reset(void);
64  static void cleanup(void);
65 
66  protected:
67  /** r */
68  int r;
69  /** count */
70  int count;
71 
72  private:
73  static RhtRNode* reuse_head;
74  static RhtRNode* reuse_tail;
75 };
76 
77 class RhtYNode : public RhtAccNode
78 {
79  private:
80  static RhtYNode* reuse_head;
81  static RhtYNode* reuse_tail;
82  public:
83  static RhtYNode* generate(int y);
84  static void reset(void);
85  static void cleanup(void);
86 
87  protected:
88  /** y */
89  int y;
90  /** r_root */
92 
93  public:
94  RhtYNode(int y);
95  int insert(int y, int r);
96  void dump(std::ostream&, int x);
97  void clear(int y);
98  void getNodes(std::vector< std::vector< int > > *rv, int min_votes, int x);
99 };
100 
101 class RhtXNode : public RhtAccNode
102 {
103  private:
104  static RhtXNode* reuse_head;
105  static RhtXNode* reuse_tail;
106  public:
107  static RhtXNode* generate(int x);
108  static void reset(void);
109  static void cleanup(void);
110 
111  protected:
112  /** x */
113  int x;
114  /** y root */
116 
117  public:
118  RhtXNode(int x);
119  int insert(int x, int y, int r);
120  void dump(std::ostream&);
121  void clear (int x);
122  void getNodes(std::vector< std::vector< int > > *rv, int min_votes);
123 };
124 
126 {
127  private:
128  int x_max;
129  int y_max;
130  int r_max;
131  int max;
132 
133  RhtXNode* root;
134 
135  int num_votes;
136 
137  public:
138  RhtAccumulator();
139  ~RhtAccumulator();
140  int accumulate(int x, int y, int r);
141  int getMax(int& x, int& y, int& r) const;
142  void dump(std::ostream&);
143  void reset(void);
144  unsigned int getNumVotes() const;
145  std::vector< std::vector< int > > * getNodes(int min_count);
146 };
147 
148 } // end namespace firevision
149 
150 #endif
Hough-Transform accumulator.
Definition: ht_accum.h:125
virtual ~RhtAccNode()
Destructor.
Definition: ht_accum.cpp:69
RhtRNode * r_root
r_root
Definition: ht_accum.h:91
RhtAccNode * left
left
Definition: ht_accum.h:45
Hough-Transform accumulator node.
Definition: ht_accum.h:36
int count
count
Definition: ht_accum.h:70
Hough-Transform accumulator node.
Definition: ht_accum.h:52
virtual void clear(int ignore)
Clear.
Definition: ht_accum.cpp:77
RhtAccNode * next
used for recycling
Definition: ht_accum.h:49
Hough-Transform accumulator node.
Definition: ht_accum.h:77
RhtYNode * y_root
y root
Definition: ht_accum.h:115
RhtAccNode * right
right
Definition: ht_accum.h:47
Hough-Transform accumulator node.
Definition: ht_accum.h:101
RhtAccNode()
Constructor.
Definition: ht_accum.cpp:62