00001 00002 /*************************************************************************** 00003 * ht_lines.h - Header of lines shape model 00004 * using Hough Transform 00005 * 00006 * Created: Fri Jan 13 12:40:57 2006 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 namespace firevision { 00037 #if 0 /* just to make Emacs auto-indent happy */ 00038 } 00039 #endif 00040 00041 class ROI; 00042 00043 class HtLinesModel: public ShapeModel 00044 { 00045 private: 00046 std::vector<LineShape> m_Lines; 00047 RhtAccumulator accumulator; 00048 00049 public: 00050 /** Creates a new HtLinesModel instance 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 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); 00067 virtual ~HtLinesModel(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 00078 unsigned int RHT_NR_CANDIDATES; 00079 float RHT_ANGLE_INCREMENT; 00080 float RHT_ANGLE_FROM; 00081 float RHT_ANGLE_RANGE; 00082 00083 // The following constants are used for RHT accumulator precision 00084 int RHT_R_SCALE; 00085 //const int RHT_PHI_SCALE = 8; 00086 00087 int RHT_MIN_VOTES; 00088 float RHT_MIN_VOTES_RATIO; 00089 00090 unsigned int roi_width; 00091 unsigned int roi_height; 00092 00093 }; 00094 00095 } // end namespace firevision 00096 00097 #endif // __FIREVISION_MODELS_SHAPE_HT_LINES_H_ 00098