gocam.hh

00001 /* 
00002 
00003 GoCam - A computer vision tool for extracting moves from go videos
00004 Copyright (C) 2005 Teemu Hirsimäki 
00005 Email: teemu.hirsimaki [at domain] iki.fi
00006 
00007 This program is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or (at
00010 your option) any later version.
00011 
00012 This program is distributed in the hope that it will be useful, but
00013 WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program; if not, write to the Free Software
00019 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
00020 USA.
00021 
00022 */
00023 
00024 #ifndef GOCAM_HH
00025 #define GOCAM_HH
00026 
00027 #include "geom.hh"
00028 #include "CImg.h"
00029 #include <vector>
00030 
00031 using namespace cimg_library;
00032 
00040 namespace gocam {
00041 
00060   struct Analyser {
00062     Analyser();
00063 
00067     void reset(const CImg<float> &img);
00068 
00070     void analyse();
00071 
00073     void compute_line_images();
00074 
00081     void compute_hough_image();
00082 
00092     void compute_initial_grid();
00093 
00095     void fix_end_points();
00096     
00106     void tune_line(geom::Line &line, geom::Line d1, geom::Line d2);
00107 
00112     void tune_grid();
00113 
00117     void grow_grid(bool only_once = false);
00118 
00123     void add_best_line(int series);
00124 
00128   private:
00129 
00137     std::vector<float> rho_differences(const std::vector<geom::LineRT> &vec);
00138 
00146     float score_new_line(const geom::Line &new_line, 
00147                          const geom::Line &next_line,
00148                          const std::vector<geom::Line> &lines);
00149 
00150   public:
00151 
00154 
00156     int verbose;
00157 
00159     int board_size;
00160 
00164     int line_peak_filter_width; 
00165 
00169     int hough_peak_filter_width; 
00170 
00178     float line_image_sigma;
00179 
00182     int approx_series_width;
00183 
00185     int approx_theta_remove_range;
00186         
00190     int median_peak_remove_width;
00191 
00193     int num_initial_lines;
00194 
00198     int max_initial_lines;
00199     
00201 
00202 
00203 
00206 
00207     CImg<float> image; 
00208     CImg<float> line_image; 
00209 
00211     CImg<float> weighted_line_image; 
00212 
00214     CImg<float> hough_image; 
00215 
00217     CImg<float> blurred_hough_image; 
00218 
00220     CImg<float> blurred_column_sum;
00221 
00223     int approx_theta[2];
00224 
00226     CImg<float> max_rho[2];
00227 
00233     std::vector<geom::LineRT> initial_lines[2];
00234     
00240     std::vector<geom::Line> lines[2];
00241 
00243 
00244   };
00245 
00246 };
00247 
00248 #endif /* GOCAM_HH */

Generated on Tue Apr 8 09:58:19 2008 for GoCam by  doxygen 1.4.6