color_train_widget.h

00001 
00002 /***************************************************************************
00003  *  color_train_widget.h - Color training widget
00004  *
00005  *  Created: Thu Mar 20 20:53:35 2008
00006  *  Copyright  2006  Daniel Beck
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #ifndef __FIREVISION_TOOLS_FIRESTATION_COLOR_TRAIN_WIDGET_H_
00024 #define __FIREVISION_TOOLS_FIRESTATION_COLOR_TRAIN_WIDGET_H_
00025 
00026 #include <fvutils/base/roi.h>
00027 #include <fvutils/color/colorspaces.h>
00028 
00029 #include <gtkmm.h>
00030 
00031 class ColormapViewerWidget;
00032 namespace firevision {
00033   class BayesColormapGenerator;
00034   class Zauberstab;
00035   class YuvColormap;
00036 }
00037 
00038 class ColorTrainWidget
00039 {
00040  public:
00041         static const unsigned int MOUSE_BUTTON_LEFT = 1; /**< constant for left mouse button id */
00042         static const unsigned int MOUSE_BUTTON_RIGHT = 3; /**< constant for right mouse button id */
00043 
00044   ColorTrainWidget(Gtk::Window* parent);
00045   virtual ~ColorTrainWidget();
00046 
00047   void set_fg_object(firevision::hint_t fg_object);
00048 
00049   void set_src_buffer(unsigned char* buffer,
00050                       unsigned int img_width, unsigned int img_height);
00051   void set_draw_buffer(unsigned char* buffer);
00052 
00053 
00054   void click(unsigned int x, unsigned int y, unsigned int button = MOUSE_BUTTON_LEFT);
00055   void reset_selection();
00056 
00057   void load_histograms();
00058   void save_histograms();
00059 
00060   void add_to_colormap();
00061   void reset_colormap();
00062   void load_colormap();
00063   void save_colormap();
00064   firevision::YuvColormap* get_colormap() const;
00065 
00066   void draw_segmentation_result();
00067 
00068   void set_reset_selection_btn(Gtk::Button* btn);
00069   void set_add_to_colormap_btn(Gtk::Button* btn);
00070   void set_reset_colormap_btn(Gtk::Button* btn);
00071   void set_load_histos_btn(Gtk::Button* btn);
00072   void set_save_histos_btn(Gtk::Button* btn);
00073   void set_load_colormap_btn(Gtk::Button* btn);
00074   void set_save_colormap_btn(Gtk::Button* btn);
00075   void set_colormap_img(Gtk::Image* img);
00076   void set_segmentation_img(Gtk::Image* img);
00077   void set_threshold_scl(Gtk::Scale* scl);
00078   void set_min_prob_scl(Gtk::Scale* scl);
00079   void set_filechooser_dlg(Gtk::FileChooserDialog* dlg);
00080   void set_cm_layer_selector(Gtk::Scale* scl);
00081   void set_cm_selector(Gtk::SpinButton* depth, Gtk::SpinButton* width = 0, Gtk::SpinButton* height = 0);
00082 
00083   Glib::Dispatcher& update_image();
00084   Glib::Dispatcher& colormap_updated();
00085 
00086  private:
00087   void resize_seg_image(Gtk::Allocation& allocation);
00088   bool set_threshold(Gtk::ScrollType scroll, double value);
00089   bool set_min_prob(Gtk::ScrollType scroll, double value);
00090   static void free_rgb_buffer(const guint8* rgb_buffer);
00091 
00092   void reset_gui();
00093 
00094   firevision::BayesColormapGenerator* m_generator;
00095   firevision::Zauberstab* m_zauberstab;
00096   ColormapViewerWidget* m_cvw;
00097 
00098   firevision::hint_t m_fg_object;
00099 
00100   unsigned char* m_src_buffer;
00101   unsigned char* m_draw_buffer;
00102   unsigned int m_img_width;
00103   unsigned int m_img_height;
00104   unsigned int m_img_size;
00105   firevision::colorspace_t m_img_cs;
00106   unsigned int m_seg_img_max_width;
00107   unsigned int m_seg_img_max_height;
00108 
00109   Gtk::Window* m_wnd_parent;
00110   Gtk::Button* m_btn_reset_selection;
00111   Gtk::Button* m_btn_add_to_colormap;
00112   Gtk::Button* m_btn_reset_colormap;
00113   Gtk::Button* m_btn_load_histos;
00114   Gtk::Button* m_btn_save_histos;
00115   Gtk::Button* m_btn_load_colormap;
00116   Gtk::Button* m_btn_save_colormap;
00117   Gtk::SpinButton* m_spbtn_cm_depth;
00118   Gtk::SpinButton* m_spbtn_cm_width;
00119   Gtk::SpinButton* m_spbtn_cm_height;
00120   Gtk::Image* m_img_segmentation;
00121   Gtk::Scale* m_scl_threshold;
00122   Gtk::Scale* m_scl_min_prob;
00123   Gtk::FileChooserDialog* m_fcd_filechooser;
00124 
00125   Glib::Dispatcher m_signal_update_image;
00126   Glib::Dispatcher m_signal_colormap_updated;
00127 };
00128 
00129 #endif /* __FIREVISION_TOOLS_FIRESTATION_COLOR_TRAIN_WIDGET_H_ */

Generated on Tue Feb 22 13:31:18 2011 for Fawkes API by  doxygen 1.4.7