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 class BayesColormapGenerator;
00033 class Zauberstab;
00034 class YuvColormap;
00035
00036 class ColorTrainWidget
00037 {
00038  public:
00039         static const unsigned int MOUSE_BUTTON_LEFT = 1; /**< constant for left mouse button id */
00040         static const unsigned int MOUSE_BUTTON_RIGHT = 3; /**< constant for right mouse button id */
00041
00042   ColorTrainWidget(Gtk::Window* parent);
00043   virtual ~ColorTrainWidget();
00044
00045   void set_fg_object(hint_t fg_object);
00046
00047   void set_src_buffer(unsigned char* buffer,
00048                       unsigned int img_width, unsigned int img_height);
00049   void set_draw_buffer(unsigned char* buffer);
00050
00051
00052   void click(unsigned int x, unsigned int y, unsigned int button = MOUSE_BUTTON_LEFT);
00053   void reset_selection();
00054
00055   void load_histograms();
00056   void save_histograms();
00057
00058   void add_to_colormap();
00059   void reset_colormap();
00060   void load_colormap();
00061   void save_colormap();
00062   YuvColormap* get_colormap() const;
00063
00064   void draw_segmentation_result();
00065
00066   void set_reset_selection_btn(Gtk::Button* btn);
00067   void set_add_to_colormap_btn(Gtk::Button* btn);
00068   void set_reset_colormap_btn(Gtk::Button* btn);
00069   void set_load_histos_btn(Gtk::Button* btn);
00070   void set_save_histos_btn(Gtk::Button* btn);
00071   void set_load_colormap_btn(Gtk::Button* btn);
00072   void set_save_colormap_btn(Gtk::Button* btn);
00073   void set_colormap_img(Gtk::Image* img);
00074   void set_segmentation_img(Gtk::Image* img);
00075   void set_threshold_scl(Gtk::Scale* scl);
00076   void set_min_prob_scl(Gtk::Scale* scl);
00077   void set_filechooser_dlg(Gtk::FileChooserDialog* dlg);
00078   void set_cm_layer_selector(Gtk::Scale* scl);
00079   void set_cm_selector(Gtk::SpinButton* depth, Gtk::SpinButton* width = 0, Gtk::SpinButton* height = 0);
00080
00081   Glib::Dispatcher& update_image();
00082   Glib::Dispatcher& colormap_updated();
00083
00084  private:
00085   void resize_seg_image(Gtk::Allocation& allocation);
00086   bool set_threshold(Gtk::ScrollType scroll, double value);
00087   bool set_min_prob(Gtk::ScrollType scroll, double value);
00088   static void free_rgb_buffer(const guint8* rgb_buffer);
00089
00090   void reset_gui();
00091
00092   BayesColormapGenerator* m_generator;
00093   Zauberstab* m_zauberstab;
00094   ColormapViewerWidget* m_cvw;
00095
00096   hint_t m_fg_object;
00097
00098   unsigned char* m_src_buffer;
00099   unsigned char* m_draw_buffer;
00100   unsigned int m_img_width;
00101   unsigned int m_img_height;
00102   unsigned int m_img_size;
00103   colorspace_t m_img_cs;
00104   unsigned int m_seg_img_max_width;
00105   unsigned int m_seg_img_max_height;
00106
00107   Gtk::Window* m_wnd_parent;
00108   Gtk::Button* m_btn_reset_selection;
00109   Gtk::Button* m_btn_add_to_colormap;
00110   Gtk::Button* m_btn_reset_colormap;
00111   Gtk::Button* m_btn_load_histos;
00112   Gtk::Button* m_btn_save_histos;
00113   Gtk::Button* m_btn_load_colormap;
00114   Gtk::Button* m_btn_save_colormap;
00115   Gtk::SpinButton* m_spbtn_cm_depth;
00116   Gtk::SpinButton* m_spbtn_cm_width;
00117   Gtk::SpinButton* m_spbtn_cm_height;
00118   Gtk::Image* m_img_segmentation;
00119   Gtk::Scale* m_scl_threshold;
00120   Gtk::Scale* m_scl_min_prob;
00121   Gtk::FileChooserDialog* m_fcd_filechooser;
00122
00123   Glib::Dispatcher m_signal_update_image;
00124   Glib::Dispatcher m_signal_colormap_updated;
00125 };
00126
00127 #endif /* __FIREVISION_TOOLS_FIRESTATION_COLOR_TRAIN_WIDGET_H_ */