Fawkes API  Fawkes Development Version
color_train_widget.h
1 
2 /***************************************************************************
3  * color_train_widget.h - Color training widget
4  *
5  * Created: Thu Mar 20 20:53:35 2008
6  * Copyright 2006 Daniel Beck
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef __FIREVISION_TOOLS_FIRESTATION_COLOR_TRAIN_WIDGET_H_
24 #define __FIREVISION_TOOLS_FIRESTATION_COLOR_TRAIN_WIDGET_H_
25 
26 #include <fvutils/base/roi.h>
27 #include <fvutils/color/colorspaces.h>
28 
29 #include <gtkmm.h>
30 
32 namespace firevision {
33  class BayesColormapGenerator;
34  class Zauberstab;
35  class YuvColormap;
36 }
37 
39 {
40  public:
41  static const unsigned int MOUSE_BUTTON_LEFT = 1; /**< constant for left mouse button id */
42  static const unsigned int MOUSE_BUTTON_RIGHT = 3; /**< constant for right mouse button id */
43 
44  ColorTrainWidget(Gtk::Window* parent);
45  virtual ~ColorTrainWidget();
46 
47  void set_fg_object(firevision::hint_t fg_object);
48 
49  void set_src_buffer(unsigned char* buffer,
50  unsigned int img_width, unsigned int img_height);
51  void set_draw_buffer(unsigned char* buffer);
52 
53 
54  void click(unsigned int x, unsigned int y, unsigned int button = MOUSE_BUTTON_LEFT);
55  void reset_selection();
56 
57  void load_histograms();
58  void save_histograms();
59 
60  void add_to_colormap();
61  void reset_colormap();
62  void load_colormap();
63  void save_colormap();
64  firevision::YuvColormap* get_colormap() const;
65 
66  void draw_segmentation_result();
67 
68  void set_reset_selection_btn(Gtk::Button* btn);
69  void set_add_to_colormap_btn(Gtk::Button* btn);
70  void set_reset_colormap_btn(Gtk::Button* btn);
71  void set_load_histos_btn(Gtk::Button* btn);
72  void set_save_histos_btn(Gtk::Button* btn);
73  void set_load_colormap_btn(Gtk::Button* btn);
74  void set_save_colormap_btn(Gtk::Button* btn);
75  void set_colormap_img(Gtk::Image* img);
76  void set_segmentation_img(Gtk::Image* img);
77  void set_threshold_scl(Gtk::Scale* scl);
78  void set_min_prob_scl(Gtk::Scale* scl);
79  void set_filechooser_dlg(Gtk::FileChooserDialog* dlg);
80  void set_cm_layer_selector(Gtk::Scale* scl);
81  void set_cm_selector(Gtk::SpinButton* depth, Gtk::SpinButton* width = 0, Gtk::SpinButton* height = 0);
82 
83  Glib::Dispatcher& update_image();
84  Glib::Dispatcher& colormap_updated();
85 
86  private:
87  void resize_seg_image(Gtk::Allocation& allocation);
88  bool set_threshold(Gtk::ScrollType scroll, double value);
89  bool set_min_prob(Gtk::ScrollType scroll, double value);
90  static void free_rgb_buffer(const guint8* rgb_buffer);
91 
92  void reset_gui();
93 
95  firevision::Zauberstab* m_zauberstab;
96  ColormapViewerWidget* m_cvw;
97 
98  firevision::hint_t m_fg_object;
99 
100  unsigned char* m_src_buffer;
101  unsigned char* m_draw_buffer;
102  unsigned int m_img_width;
103  unsigned int m_img_height;
104  unsigned int m_img_size;
105  firevision::colorspace_t m_img_cs;
106  unsigned int m_seg_img_max_width;
107  unsigned int m_seg_img_max_height;
108 
109  Gtk::Window* m_wnd_parent;
110  Gtk::Button* m_btn_reset_selection;
111  Gtk::Button* m_btn_add_to_colormap;
112  Gtk::Button* m_btn_reset_colormap;
113  Gtk::Button* m_btn_load_histos;
114  Gtk::Button* m_btn_save_histos;
115  Gtk::Button* m_btn_load_colormap;
116  Gtk::Button* m_btn_save_colormap;
117  Gtk::SpinButton* m_spbtn_cm_depth;
118  Gtk::SpinButton* m_spbtn_cm_width;
119  Gtk::SpinButton* m_spbtn_cm_height;
120  Gtk::Image* m_img_segmentation;
121  Gtk::Scale* m_scl_threshold;
122  Gtk::Scale* m_scl_min_prob;
123  Gtk::FileChooserDialog* m_fcd_filechooser;
124 
125  Glib::Dispatcher m_signal_update_image;
126  Glib::Dispatcher m_signal_colormap_updated;
127 };
128 
129 #endif /* __FIREVISION_TOOLS_FIRESTATION_COLOR_TRAIN_WIDGET_H_ */
YUV Colormap.
Definition: yuvcm.h:39
Zaubertab selection utility.
Definition: zauberstab.h:68
Colormap Generator using Bayes method.
This widget implements the complete color training process.
Select a layer from a colormap and render it to a Gtk::Image.