ht_accum.h

00001 
00002 /***************************************************************************
00003  *  ht_accum.h - Accumulator class for HoughTransform
00004  *
00005  *  Created: Tue Jun 28 00:00:00 2005
00006  *  Copyright  2005  Hu Yuxiao <Yuxiao.Hu@rwth-aachen.de>
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
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 /* just to make Emacs auto-indent happy */
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   /** left */
00045   RhtAccNode* left;
00046   /** right */
00047   RhtAccNode* right;
00048   /** used for recycling */
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   /** r */
00068   int r;
00069   /** count */
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   /** y */
00089   int y;
00090   /** r_root */
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   /** x */
00113   int x;
00114   /** y root */
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 } // end namespace firevision
00149 
00150 #endif

Generated on Tue Feb 22 13:32:16 2011 for Fawkes API by  doxygen 1.4.7