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