24 #include <core/exceptions/software.h> 25 #include <utils/system/argparser.h> 26 #include <utils/time/tracker.h> 28 #include <fvcams/factory.h> 30 #include <fvcams/shmem.h> 32 #ifdef HAVE_NETWORK_CAM 33 #include <fvcams/net.h> 35 #ifdef HAVE_FILELOADER_CAM 36 #include <fvcams/fileloader.h> 45 #include <fvutils/color/conversions.h> 50 Gtk::Image *img_image;
58 unsigned int loop_count = 0;
73 unsigned char *rgb_buffer = malloc_buffer(RGB, orig_width, orig_height);
76 orig_width, orig_height);
80 Glib::RefPtr<Gdk::Pixbuf> image =
81 Gdk::Pixbuf::create_from_data( rgb_buffer, Gdk::COLORSPACE_RGB,
false,
82 8, orig_width, orig_height, 3 * orig_width);
84 int width = img_image->get_width();
85 int height = img_image->get_height();
86 Glib::RefPtr<Gdk::Pixbuf> scaled = image->scale_simple(width, height,
89 img_image->set(scaled);
90 img_image->queue_draw();
98 if (++loop_count >= 10) {
110 print_usage(
const char *program_name)
112 printf(
"Usage: %s -n host[:port]/image_id [-j] [-d delay] [-v]\n\n" 113 " -n net_string Open network camera, the camera string is of the form\n" 114 " host[:port]/image_id. You have to specify at least the host\n" 115 " and the image_id, the port is optional and defaults to 5000\n" 116 " -j Receive JPEG images, only valid with -n\n" 117 " -d delay Delay in ms before a new image is capture.\n",
124 main(
int argc,
char **argv)
128 Gtk::Main gtk_main(argc, argv);
133 if ( argp.has_arg(
"d") ) {
134 delay = atoi(argp.arg(
"d"));
135 if ( delay < 0 ) delay = 300;
138 if ( argp.has_arg(
"h") ) {
139 print_usage(argp.program_name());
141 }
else if ( argp.has_arg(
"n") ) {
142 char *net_string = strdup(argp.arg(
"n"));
143 char *image_id = NULL, *host = NULL, *port = NULL, *save_ptr = NULL;
147 hostport = strtok_r(net_string,
"/", &save_ptr);
148 image_id = strtok_r(NULL,
"", &save_ptr);
150 if ( strchr(hostport,
':') != NULL ) {
151 host = strtok_r(hostport,
":", &save_ptr);
152 port = strtok_r(NULL,
"", &save_ptr);
157 if ( port != NULL ) {
158 port_num = atoi(port);
159 if ( (port_num < 0) || (port_num > 0xFFFF) ) {
164 if( image_id == NULL ) {
168 cam =
new NetworkCamera(host, port_num, image_id, argp.has_arg(
"j"));
171 print_usage(argp.program_name());
179 printf(
"Failed to open camera\n");
188 ttc_interloop = tt.
add_class(
"InterLoop");
191 Glib::RefPtr<Gtk::Builder> builder;
193 Gtk::Builder::create_from_file(RESDIR
"/guis/scale_viewer/scale_viewer.ui");
197 builder->get_widget(
"wnd_main", window);
198 builder->get_widget(
"img_image", img_image);
200 Glib::signal_timeout().connect(sigc::ptr_fun(&timeout_handler), delay);
202 window->set_size_request(320, 240);
203 Gtk::Main::run(*window);
void ping_start(unsigned int cls)
Start of given class task.
Camera interface for image aquiring devices in FireVision.
Fawkes library namespace.
virtual unsigned int pixel_width()=0
Width of image in pixels.
Parse command line arguments.
virtual colorspace_t colorspace()=0
Colorspace of returned image.
Base class for exceptions in Fawkes.
virtual void capture()=0
Capture an image.
unsigned int add_class(std::string name)
Add a new class.
void ping_end(unsigned int cls)
End of given class task.
virtual void open()=0
Open the camera.
void print_to_stdout()
Print results to stdout.
void print_trace()
Prints trace to stderr.
virtual void close()=0
Close camera.
virtual unsigned char * buffer()=0
Get access to current image buffer.
virtual unsigned int pixel_height()=0
Height of image in pixels.
virtual void start()=0
Start image transfer from the camera.
Expected parameter is missing.
virtual void dispose_buffer()=0
Dispose current buffer.