Fawkes API  Fawkes Development Version
firestation.h
1 
2 /***************************************************************************
3  * firestation.h - Firestation
4  *
5  * Created: Wed Oct 10 14:15:56 2007
6  * Copyright 2007 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_FIRESTATION_H_
24 #define __FIREVISION_TOOLS_FIRESTATION_FIRESTATION_H_
25 
26 #include <gtkmm.h>
27 #include <fvutils/base/roi.h>
28 #include <fvutils/color/colorspaces.h>
29 #include <netcomm/dns-sd/avahi_thread.h>
30 
31 namespace firevision {
32  class Camera;
33  class SharedMemoryImageBuffer;
34  class ShmImageLister;
35  class Writer;
36  class FuseImageListWidget;
37  class MirrorCalibTool;
38 }
39 namespace fawkes {
40  class AvahiDispatcher;
41 }
42 class ColorTrainTool;
43 class ColorTrainWidget;
44 class FuseTransferWidget;
45 
46 class Firestation : public Gtk::Window
47 {
48  public:
49  Firestation(Glib::RefPtr<Gtk::Builder> builder);
50  virtual ~Firestation();
51 
52  Gtk::Window& get_window() const;
53 
54  private:
55  class ShmColumnRecord : public Gtk::TreeModel::ColumnRecord
56  {
57  public:
58  ShmColumnRecord()
59  {
60  add(m_id); add(m_name);
61  };
62  /// @cond INTERNALS
63  Gtk::TreeModelColumn<int> m_id;
64  Gtk::TreeModelColumn<Glib::ustring> m_name;
65  /// @endcond
66  };
67 
68  class FuseColumnRecord : public Gtk::TreeModel::ColumnRecord
69  {
70  public:
71  FuseColumnRecord()
72  {
73  add(m_id); add(m_name);
74  add(m_service_name); add(m_service_domain);
75  add(m_service_hostname); add(m_service_port);
76  add(m_image_id); add(m_image_width), add(m_image_height);
77  add(m_image_colorspace);
78  };
79  /// @cond INTERNALS
80  Gtk::TreeModelColumn<int> m_id;
81  Gtk::TreeModelColumn<Glib::ustring> m_name;
82  Gtk::TreeModelColumn<Glib::ustring> m_service_name;
83  Gtk::TreeModelColumn<Glib::ustring> m_service_type;
84  Gtk::TreeModelColumn<Glib::ustring> m_service_domain;
85  Gtk::TreeModelColumn<Glib::ustring> m_service_hostname;
86  Gtk::TreeModelColumn<unsigned short int> m_service_port;
87  Gtk::TreeModelColumn<Glib::ustring> m_image_id;
88  Gtk::TreeModelColumn<unsigned int> m_image_width;
89  Gtk::TreeModelColumn<unsigned int> m_image_height;
90  Gtk::TreeModelColumn<Glib::ustring> m_image_colorspace;
91  /// @endcond
92  };
93 
94  typedef enum
95  {
96  SRC_NONE,
97  SRC_FILE,
98  SRC_SHM,
99  SRC_FUSE
100  } ImageSource;
101 
102  typedef enum
103  {
104  MODE_VIEWER,
105  MODE_COLOR_TRAIN,
106  MODE_MIRROR_CALIB,
107  MODE_MIRROR_CALIB_EVAL
108  } OpMode;
109 
110  void save_image();
111  void exit();
112  void close_camera();
113  void update_image();
114  bool call_update_image();
115  void enable_cont_img_trans();
116  void open_file();
117  void open_folder();
118  void open_shm();
119  void open_fuse();
120  void on_fuse_image_selected();
121  void on_colormap_updated();
122  bool image_click(GdkEventButton*);
123 
124  void on_service_added( fawkes::NetworkService* service );
125  void on_service_removed( fawkes::NetworkService* service );
126 
127  void pre_open_img_src();
128  void post_open_img_src();
129  void resize_image(Gtk::Allocation& allocation);
130  void draw_image();
131 
132  void ct_start();
133  firevision::hint_t ct_get_fg_object();
134  void ct_object_changed();
135 
136  double mc_line_angle_deg;
137  void mc_load_mask();
138  void mc_set_center();
139  void mc_memorize();
140  void mc_simulate_clicks();
141  void mc_draw_line();
142  bool mc_on_line_angle_changed(Gtk::ScrollType scroll, double value);
143  void mc_save();
144  void mc_load();
145 
146  Glib::Dispatcher m_update_img;
147 
148  fawkes::AvahiDispatcher* m_avahi_dispatcher;
149 
150  // widgets
151  Gtk::Window* m_wnd_main;
152  Gtk::Dialog* m_dlg_open_shm;
153  Gtk::Dialog* m_dlg_open_fuse;
154  Gtk::CheckButton* m_ckb_fuse_jpeg;
155  Gtk::CheckButton* m_ckb_cont_trans;
156  Gtk::SpinButton* m_spb_update_time;
157  Gtk::FileChooserDialog* m_fcd_open_image;
158  Gtk::FileChooserDialog* m_fcd_save_image;
159  Gtk::ToolButton* m_tbtn_open_file;
160  Gtk::ToolButton* m_tbtn_open_folder;
161  Gtk::ToolButton* m_tbtn_open_shm;
162  Gtk::ToolButton* m_tbtn_open_fuse;
163  Gtk::ToolButton* m_tbtn_update;
164  Gtk::ToolButton* m_tbtn_save;
165  Gtk::ToolButton* m_tbtn_close_camera;
166  Gtk::ToolButton* m_tbtn_exit;
167  Gtk::Image* m_img_image;
168  Gtk::EventBox* m_evt_image;
169  Gtk::TreeView* m_trv_shm_image_ids;
170  Gtk::TreeView* m_trv_fuse_services;
171  Gtk::Statusbar* m_stb_status;
172 
173  // color training widgets
174  Gtk::ComboBox* m_cmb_ct_type;
175  Gtk::ToggleButton* m_btn_ct_start;
176  Gtk::ToggleButton* m_btn_ct_seg;
177  Gtk::SpinButton* m_spbtn_depth;
178  Gtk::SpinButton* m_spbtn_width;
179  Gtk::SpinButton* m_spbtn_height;
180 
181  // mirror calibration widgets
182  Gtk::FileChooserDialog* m_fcd_mc_load_mask;
183  Gtk::FileChooserDialog* m_fcd_mc_save;
184  Gtk::FileChooserDialog* m_fcd_mc_load;
185  Gtk::Button* m_btn_mc_load_mask;
186  Gtk::ToggleButton* m_btn_mc_set_center;
187  Gtk::Button* m_btn_mc_memorize;
188  Gtk::Button* m_btn_mc_simulate_clicks;
189  Gtk::Scale* m_scl_mc_line;
190  Gtk::Button* m_btn_mc_load;
191  Gtk::Button* m_btn_mc_save;
192  Gtk::Entry* m_ent_mc_dist;
193  Gtk::Entry* m_ent_mc_ori;
194 
195  ShmColumnRecord m_shm_columns;
196  Glib::RefPtr<Gtk::ListStore> m_shm_list_store;
197 
198  FuseColumnRecord m_fuse_columns;
199  Glib::RefPtr<Gtk::TreeStore> m_fuse_tree_store;
200 
202  firevision::Camera* m_camera;
203  firevision::Writer* m_img_writer;
204 
205  ImageSource m_img_src;
206  OpMode m_op_mode;
207 
208  // image buffer
209  unsigned char* m_yuv_orig_buffer;
210  unsigned char* m_yuv_draw_buffer;
211  unsigned char* m_yuv_scaled_buffer;
212  unsigned char* m_rgb_scaled_buffer;
213 
214  unsigned int m_img_width;
215  unsigned int m_img_height;
216  unsigned int m_scaled_img_width;
217  unsigned int m_scaled_img_height;
218  unsigned int m_max_img_width;
219  unsigned int m_max_img_height;
220 
221  firevision::colorspace_t m_img_cs;
222  size_t m_img_size;
223  bool m_cont_img_trans;
224  float m_scale_factor;
225 
226 #ifdef HAVE_MIRROR_CALIB
227  firevision::MirrorCalibTool* m_calib_tool;
228 #endif
229  ColorTrainWidget* m_ctw;
230  FuseTransferWidget* m_ftw;
232 
233  fawkes::AvahiThread* m_avahi_thread;
234 };
235 
236 #endif /* __FIREVISION_TOOLS_FIRESTATION_FIRESTATION_H_ */
Camera interface for image aquiring devices in FireVision.
Definition: camera.h:35
Avahi dispatcher.
This widget displays all available Fuse images in a tree view.
This class implements the logic for a GUI that allows to transfer LUTs via FUSE.
Fawkes library namespace.
Interface to write images.
Definition: writer.h:34
Shared memory image buffer.
Definition: shm_image.h:181
Avahi main thread.
Definition: avahi_thread.h:54
Representation of a service announced or found via service discovery (i.e.
Definition: service.h:37
This class encapsulates the routines necessary for interactive mirror calibration.
Definition: mirror_calib.h:43
This widget implements the complete color training process.
Control GUI for vision related stuff.
Definition: firestation.h:46