rht_lines.h

00001
00002 /***************************************************************************
00003  *  rht_lines.h - Header of lines shape model
00004  *                 using Randomized Hough Transform
00005  *
00006  *  Generated: Mon Sep 26 2005 09:48:55
00007  *  Copyright  2005  Tim Niemueller [www.niemueller.de]
00008  *
00009  ****************************************************************************/
00010
00011 /*  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version. A runtime exception applies to
00015  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00016  *
00017  *  This program is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU Library General Public License for more details.
00021  *
00022  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00023  */
00024
00025 #ifndef __FIREVISION_MODELS_SHAPE_RHT_LINE_H_
00026 #define __FIREVISION_MODELS_SHAPE_RHT_LINE_H_
00027 
00028 #include <vector>
00029 #include <iostream>
00030 #include <cmath>
00031
00032 #include <fvutils/base/types.h>
00033 #include <models/shape/line.h>
00034 #include <models/shape/accumulators/ht_accum.h>
00035
00036 class ROI;
00037
00038 class RhtLinesModel: public ShapeModel
00039 {
00040  private:
00041   std::vector<LineShape> m_Lines;
00042   RhtAccumulator accumulator;
00043
00044  public:
00045   /** Creates a new RhtLinesModel instance
00046    * @param max_time the maximum runtime of a single parseImage call in seconds,
00047    *                     if you set max_iter to a small number this time may not
00048    *                     be used completely
00049    * @param max_iter the maximum number of iterations one parseImage will do,
00050    *                 if you set max_time to a short time this number may not be reached
00051    * @param nr_candidates the nr of candidates that is considered per pixel (the hole angle
00052    *                      range is devided in this many parts/lines
00053    * @param angle_from The angle to start the candidates from, given in rad, 0 is straight up
00054    * @param angle_range the angle range the candidates are taken from starting at angle_from,
00055    *                    given in rad, can be used for example to only search for horizontal lines
00056    * @param r_scale This can be done to reduce the size of the hough space and to map more lines
00057    *                to one line
00058    * @param min_votes_ratio The minimum ratio num_votes_per_line/total_num_votes that we have to
00059    *                        have before a point in the hough space is considered to be a line,
00060    *                        this may actually be higher if you use min_votes and set it to a higher
00061    *                        number (set min_votes to 0 to only use min_votes_ration)
00062    * @param min_votes the minimum number of votes a point in the hough space has to have before it
00063    *                  is considered to be a line. The number may actually be higher if min_votes_ratio
00064    *                  is set too high (set min_votes_ration to 0 to use only min_votes)
00065    */
00066   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);
00067   virtual ~RhtLinesModel(void);
00068
00069   std::string   getName(void) const {return std::string("RhtLinesModel");}
00070   int           parseImage(unsigned char* buffer, ROI *roi);
00071   int           getShapeCount(void) const;
00072   LineShape*         getShape(int id) const;
00073   LineShape*            getMostLikelyShape(void) const;
00074   std::vector< LineShape > * getShapes();
00075
00076  private:
00077   // The following constants are used as stopping criteria
00078   float         RHT_MAX_TIME;
00079   int           RHT_MAX_ITER;
00080
00081   unsigned int  RHT_NR_CANDIDATES;
00082   float         RHT_ANGLE_INCREMENT;
00083   float         RHT_ANGLE_FROM;
00084   float         RHT_ANGLE_RANGE;
00085
00086   // The following constants are used for RHT accumulator precision
00087   int           RHT_R_SCALE;
00088   //const int             RHT_PHI_SCALE   = 8;
00089
00090   int           RHT_MIN_VOTES;
00091   float         RHT_MIN_VOTES_RATIO;
00092
00093   unsigned int  roi_width;
00094   unsigned int  roi_height;
00095
00096
00097   int                    diff_sec;
00098   int                    diff_usec;
00099
00100   float                  f_diff_sec;
00101
00102 };
00103
00104 #endif // __FIREVISION_MODELS_SHAPE_RHT_LINES_H_
00105