ht_lines.h

00001
00002 /***************************************************************************
00003  *  ht_lines.h - Header of lines shape model
00004  *               using Hough Transform
00005  *
00006  *  Generated: Fri Jan 13 2006 12:40:57
00007  *  Copyright  2005-2006  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_HT_LINE_H_
00026 #define __FIREVISION_MODELS_SHAPE_HT_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 HtLinesModel: public ShapeModel
00039 {
00040  private:
00041   std::vector<LineShape> m_Lines;
00042   RhtAccumulator accumulator;
00043
00044  public:
00045   /** Creates a new HtLinesModel instance
00046    * @param nr_candidates the nr of candidates that is considered per pixel (the hole angle
00047    *                      range is devided in this many parts/lines
00048    * @param angle_from The angle to start the candidates from, given in rad, 0 is straight up
00049    * @param angle_range the angle range the candidates are taken from starting at angle_from,
00050    *                    given in rad, can be used for example to only search for horizontal lines
00051    * @param r_scale This can be done to reduce the size of the hough space and to map more lines
00052    *                to one line
00053    * @param min_votes_ratio The minimum ratio num_votes_per_line/total_num_votes that we have to
00054    *                        have before a point in the hough space is considered to be a line,
00055    *                        this may actually be higher if you use min_votes and set it to a higher
00056    *                        number (set min_votes to 0 to only use min_votes_ration)
00057    * @param min_votes the minimum number of votes a point in the hough space has to have before it
00058    *                  is considered to be a line. The number may actually be higher if min_votes_ratio
00059    *                  is set too high (set min_votes_ration to 0 to use only min_votes)
00060    */
00061   HtLinesModel(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);
00062   virtual ~HtLinesModel(void);
00063
00064   std::string   getName(void) const {return std::string("RhtLinesModel");}
00065   int           parseImage(unsigned char* buffer, ROI *roi);
00066   int           getShapeCount(void) const;
00067   LineShape*    getShape(int id) const;
00068   LineShape*    getMostLikelyShape(void) const;
00069   std::vector< LineShape > * getShapes();
00070
00071  private:
00072
00073   unsigned int  RHT_NR_CANDIDATES;
00074   float         RHT_ANGLE_INCREMENT;
00075   float         RHT_ANGLE_FROM;
00076   float         RHT_ANGLE_RANGE;
00077
00078   // The following constants are used for RHT accumulator precision
00079   int           RHT_R_SCALE;
00080   //const int             RHT_PHI_SCALE   = 8;
00081
00082   int           RHT_MIN_VOTES;
00083   float         RHT_MIN_VOTES_RATIO;
00084
00085   unsigned int  roi_width;
00086   unsigned int  roi_height;
00087
00088 };
00089
00090 #endif // __FIREVISION_MODELS_SHAPE_HT_LINES_H_
00091