Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * rht_lines.h - Header of lines shape model 00004 * using Randomized Hough Transform 00005 * 00006 * Created: 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 <fvmodels/shape/line.h> 00034 #include <fvmodels/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 RhtLinesModel: public ShapeModel 00044 { 00045 private: 00046 std::vector<LineShape> m_Lines; 00047 RhtAccumulator accumulator; 00048 00049 public: 00050 /** Creates a new RhtLinesModel instance 00051 * @param max_time the maximum runtime of a single parseImage call in seconds, 00052 * if you set max_iter to a small number this time may not 00053 * be used completely 00054 * @param max_iter the maximum number of iterations one parseImage will do, 00055 * if you set max_time to a short time this number may not be reached 00056 * @param nr_candidates the nr of candidates that is considered per pixel (the hole angle 00057 * range is devided in this many parts/lines 00058 * @param angle_from The angle to start the candidates from, given in rad, 0 is straight up 00059 * @param angle_range the angle range the candidates are taken from starting at angle_from, 00060 * given in rad, can be used for example to only search for horizontal lines 00061 * @param r_scale This can be done to reduce the size of the hough space and to map more lines 00062 * to one line 00063 * @param min_votes_ratio The minimum ratio num_votes_per_line/total_num_votes that we have to 00064 * have before a point in the hough space is considered to be a line, 00065 * this may actually be higher if you use min_votes and set it to a higher 00066 * number (set min_votes to 0 to only use min_votes_ration) 00067 * @param min_votes the minimum number of votes a point in the hough space has to have before it 00068 * is considered to be a line. The number may actually be higher if min_votes_ratio 00069 * is set too high (set min_votes_ration to 0 to use only min_votes) 00070 */ 00071 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); 00072 virtual ~RhtLinesModel(void); 00073 00074 std::string getName(void) const {return std::string("RhtLinesModel");} 00075 int parseImage(unsigned char* buffer, ROI *roi); 00076 int getShapeCount(void) const; 00077 LineShape* getShape(int id) const; 00078 LineShape* getMostLikelyShape(void) const; 00079 std::vector< LineShape > * getShapes(); 00080 00081 private: 00082 // The following constants are used as stopping criteria 00083 float RHT_MAX_TIME; 00084 int RHT_MAX_ITER; 00085 00086 unsigned int RHT_NR_CANDIDATES; 00087 float RHT_ANGLE_INCREMENT; 00088 float RHT_ANGLE_FROM; 00089 float RHT_ANGLE_RANGE; 00090 00091 // The following constants are used for RHT accumulator precision 00092 int RHT_R_SCALE; 00093 //const int RHT_PHI_SCALE = 8; 00094 00095 int RHT_MIN_VOTES; 00096 float RHT_MIN_VOTES_RATIO; 00097 00098 unsigned int roi_width; 00099 unsigned int roi_height; 00100 00101 00102 int diff_sec; 00103 int diff_usec; 00104 00105 float f_diff_sec; 00106 00107 }; 00108 00109 } // end namespace firevision 00110 00111 #endif // __FIREVISION_MODELS_SHAPE_RHT_LINES_H_ 00112