Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi! is there a way to use gtk2 in viewing webcam stream? what widgets should i use? can i use a pixbufloader in reading stream from the webcam? and can i use a gtk2::image to view the live video from webcam? tnx.

Replies are listed 'Best First'.
Re: Gtk2 Webcam?
by zentara (Cardinal) on Feb 01, 2010 at 13:27 UTC
    For simple image grabs, Gtk2::Imageviewer will display anything it supports (built with)

    For video, you need to look at WebKit which has a working gstreamer built right in. Read the gstreamer faq

    Webkit is the lib to use now for html access. It plays videos. It has a perl module too Gtk2::Webkit

    Gstreamer has it's own perl module also, if you don't need to view the camera stream thru a web address.

    Webkit takes awhile to build, and has a few required dependencies; but it plays youtube videos right inside a Gtk2 window. I tested it all yesterday, and it all works. (You may also be able to use mplayer, embedded into a Gtk2 window. Google for examples.

    #!/usr/bin/perl use strict; use warnings; use Gtk2 -init; use Gtk2::WebKit; my $view = Gtk2::WebKit::WebView->new; my $sw = Gtk2::ScrolledWindow->new; $sw->add($view); my $win = Gtk2::Window->new; $win->set_default_size(800, 600); $win->signal_connect(destroy => sub { Gtk2->main_quit }); $win->add($sw); $win->show_all; $view->open( $ARGV[0] // 'http://www.perlmonks.org' ); Gtk2->main;

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku