ht_accum.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __FIREVISION_MODELS_SHAPE_ACCUMULATORS_HT_ACCUM_H_
00025 #define __FIREVISION_MODELS_SHAPE_ACCUMULATORS_HT_ACCUM_H_
00026
00027 #include <stdlib.h>
00028 #include <ostream>
00029 #include <vector>
00030
00031 namespace firevision {
00032 #if 0
00033 }
00034 #endif
00035
00036 class RhtAccNode
00037 {
00038 public:
00039 RhtAccNode();
00040 virtual ~RhtAccNode();
00041 virtual void clear(int ignore);
00042
00043 protected:
00044
00045 RhtAccNode* left;
00046
00047 RhtAccNode* right;
00048
00049 RhtAccNode* next;
00050 };
00051
00052 class RhtRNode : public RhtAccNode
00053 {
00054 public:
00055 RhtRNode(int r);
00056 void clear(void);
00057 int insert(int r);
00058 void dump(std::ostream&, int x, int y);
00059 void clear(int r);
00060 void getNodes(std::vector< std::vector< int > > *rv, int min_votes, int x, int y);
00061
00062 static RhtRNode* generate(int r);
00063 static void reset(void);
00064 static void cleanup(void);
00065
00066 protected:
00067
00068 int r;
00069
00070 int count;
00071
00072 private:
00073 static RhtRNode* reuse_head;
00074 static RhtRNode* reuse_tail;
00075 };
00076
00077 class RhtYNode : public RhtAccNode
00078 {
00079 private:
00080 static RhtYNode* reuse_head;
00081 static RhtYNode* reuse_tail;
00082 public:
00083 static RhtYNode* generate(int y);
00084 static void reset(void);
00085 static void cleanup(void);
00086
00087 protected:
00088
00089 int y;
00090
00091 RhtRNode* r_root;
00092
00093 public:
00094 RhtYNode(int y);
00095 int insert(int y, int r);
00096 void dump(std::ostream&, int x);
00097 void clear(int y);
00098 void getNodes(std::vector< std::vector< int > > *rv, int min_votes, int x);
00099 };
00100
00101 class RhtXNode : public RhtAccNode
00102 {
00103 private:
00104 static RhtXNode* reuse_head;
00105 static RhtXNode* reuse_tail;
00106 public:
00107 static RhtXNode* generate(int x);
00108 static void reset(void);
00109 static void cleanup(void);
00110
00111 protected:
00112
00113 int x;
00114
00115 RhtYNode* y_root;
00116
00117 public:
00118 RhtXNode(int x);
00119 int insert(int x, int y, int r);
00120 void dump(std::ostream&);
00121 void clear (int x);
00122 void getNodes(std::vector< std::vector< int > > *rv, int min_votes);
00123 };
00124
00125 class RhtAccumulator
00126 {
00127 private:
00128 int x_max;
00129 int y_max;
00130 int r_max;
00131 int max;
00132
00133 RhtXNode* root;
00134
00135 int num_votes;
00136
00137 public:
00138 RhtAccumulator();
00139 ~RhtAccumulator();
00140 int accumulate(int x, int y, int r);
00141 int getMax(int& x, int& y, int& r) const;
00142 void dump(std::ostream&);
00143 void reset(void);
00144 unsigned int getNumVotes() const;
00145 std::vector< std::vector< int > > * getNodes(int min_count);
00146 };
00147
00148 }
00149
00150 #endif