Fawkes API  Fawkes Development Version
fc_accum.h
00001 /***************************************************************************
00002  *  fc_accum.h - Header for 'fitted circle' accumulator
00003  *               used by Randomized Stable Circle Fitting Algorithm
00004  *
00005  *  Created: Fri Sep 09 22:47:55 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_FC_ACCUM_H_
00025 #define __FIREVISION_MODELS_SHAPE_ACCUMULATORS_FC_ACCUM_H_
00026 
00027 #include <utils/math/types.h>
00028 #include <fvutils/base/types.h>
00029 #include <models/shape/circle.h>
00030 
00031 namespace firevision {
00032 #if 0 /* just to make Emacs auto-indent happy */
00033 }
00034 #endif
00035 
00036 class FittedCircle
00037 {
00038  private:
00039   static const float TOO_SMALL_DELTA;
00040 
00041 private:
00042   int count;
00043   struct circle_matrix
00044   {
00045     float A00, A01, A02;
00046     float A10, A11, A12;
00047     float A20, A21, A22;
00048 
00049     float  b0,  b1,  b2;
00050   } circle_matrices[2];
00051   int current_circle;
00052   bool point_added;
00053 
00054  public:
00055   FittedCircle(void);
00056   ~FittedCircle(void);
00057 
00058   void reset(void);
00059   float addPoint(const fawkes::point_t&); // add a new point
00060   // and return the distance from it to the fitted circle
00061   void removePoint(const fawkes::point_t&); // remove a point
00062 
00063   float distanceTo(const fawkes::point_t&, bool current = true);
00064 
00065   void commit(void);
00066   int getCount(void) const;
00067   Circle* getCircle(void) const;
00068 
00069  private:
00070   Circle* fitCircle(circle_matrix* p) const;
00071 };
00072 
00073 } // end namespace firevision
00074 
00075 #endif