23 #include <core/exceptions/software.h>
24 #include <fvcams/factory.h>
25 #include <utils/system/argparser.h>
26 #include <utils/time/tracker.h>
28 # include <fvcams/shmem.h>
30 #ifdef HAVE_NETWORK_CAM
31 # include <fvcams/net.h>
33 #ifdef HAVE_FILELOADER_CAM
34 # include <fvcams/fileloader.h>
37 #include <fvutils/color/conversions.h>
45 using namespace firevision;
47 Gtk::Image *img_image;
55 unsigned int loop_count = 0;
70 unsigned char *rgb_buffer = malloc_buffer(RGB, orig_width, orig_height);
72 convert(cam->
colorspace(), RGB, cam->
buffer(), rgb_buffer, orig_width, orig_height);
76 Glib::RefPtr<Gdk::Pixbuf> image = Gdk::Pixbuf::create_from_data(
77 rgb_buffer, Gdk::COLORSPACE_RGB,
false, 8, orig_width, orig_height, 3 * orig_width);
79 int width = img_image->get_width();
80 int height = img_image->get_height();
81 Glib::RefPtr<Gdk::Pixbuf> scaled = image->scale_simple(width, height, Gdk::INTERP_NEAREST);
83 img_image->set(scaled);
84 img_image->queue_draw();
92 if (++loop_count >= 10) {
102 print_usage(
const char *program_name)
104 printf(
"Usage: %s -n host[:port]/image_id [-j] [-d delay] [-v]\n\n"
105 " -n net_string Open network camera, the camera string is of the form\n"
106 " host[:port]/image_id. You have to specify at least the host\n"
107 " and the image_id, the port is optional and defaults to 5000\n"
108 " -j Receive JPEG images, only valid with -n\n"
109 " -d delay Delay in ms before a new image is capture.\n",
114 main(
int argc,
char **argv)
118 Gtk::Main gtk_main(argc, argv);
123 if (argp.has_arg(
"d")) {
124 delay = atoi(argp.arg(
"d"));
129 if (argp.has_arg(
"h")) {
130 print_usage(argp.program_name());
132 }
else if (argp.has_arg(
"n")) {
133 char *net_string = strdup(argp.arg(
"n"));
137 char *save_ptr = NULL;
141 hostport = strtok_r(net_string,
"/", &save_ptr);
142 image_id = strtok_r(NULL,
"", &save_ptr);
144 if (strchr(hostport,
':') != NULL) {
145 host = strtok_r(hostport,
":", &save_ptr);
146 port = strtok_r(NULL,
"", &save_ptr);
152 port_num = atoi(port);
153 if ((port_num < 0) || (port_num > 0xFFFF)) {
158 if (image_id == NULL) {
162 cam =
new NetworkCamera(host, port_num, image_id, argp.has_arg(
"j"));
165 print_usage(argp.program_name());
173 printf(
"Failed to open camera\n");
182 ttc_interloop = tt.
add_class(
"InterLoop");
185 Glib::RefPtr<Gtk::Builder> builder;
186 builder = Gtk::Builder::create_from_file(RESDIR
"/guis/scale_viewer/scale_viewer.ui");
190 builder->get_widget(
"wnd_main", window);
191 builder->get_widget(
"img_image", img_image);
193 Glib::signal_timeout().connect(sigc::ptr_fun(&timeout_handler), delay);
195 window->set_size_request(320, 240);
196 Gtk::Main::run(*window);
Parse command line arguments.
Base class for exceptions in Fawkes.
void print_trace() noexcept
Prints trace to stderr.
Expected parameter is missing.
void print_to_stdout()
Print results to stdout.
unsigned int add_class(std::string name)
Add a new class.
void ping_end(unsigned int cls)
End of given class task.
void ping_start(unsigned int cls)
Start of given class task.
Camera interface for image aquiring devices in FireVision.
virtual void close()=0
Close camera.
virtual unsigned int pixel_height()=0
Height of image in pixels.
virtual void dispose_buffer()=0
Dispose current buffer.
virtual unsigned int pixel_width()=0
Width of image in pixels.
virtual void open()=0
Open the camera.
virtual void capture()=0
Capture an image.
virtual colorspace_t colorspace()=0
Colorspace of returned image.
virtual unsigned char * buffer()=0
Get access to current image buffer.
virtual void start()=0
Start image transfer from the camera.
Fawkes library namespace.