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

Hi,

Does anyone know of any Perl modules that would pop up a simple window and have a "Take Picture" button to capture the image?

I've used Win32::Scanner to access USB webcams and it's fine but all the software that seems to come with the cams these days is fancy family album type stuff and I just want a wee pop up window that frames and takes a picture.

Any pointers much appreciated.

Many thanks
David

Replies are listed 'Best First'.
Re: perly webcam generic interface
by zentara (Cardinal) on Jul 01, 2003 at 16:10 UTC
    Here is a tk script which will continually grab an image from a webcam URL, you could modify it to save the current image with a button press.
    #!/usr/bin/perl -w use strict; use Tk; use LWP::UserAgent; use Tk::JPEG; use MIME::Base64; my $ua = LWP::UserAgent->new( timeout => 30, keep_alive => 1 ); sub get_photo { my $r = $ua->get('http://localhost/~zentara/images/webcam.jpg'); return $r->content if $r->is_success; } my $mw = new MainWindow; my $l = $mw->Label( -text => 'Zcam', -foreground => 'blue', -font => [qw/-size 100 -slant italic/] ); $l->pack(); my $time = localtime; my $datelabel = $mw->Label(-text => $time )->pack(-expand => 1, -fill +=> 'both'); $mw->Button(-text => 'Quit', -command => [destroy => $mw])->pack; $mw->repeat( #10000 = 10 second update 10000 => sub { $l->configure( -image => $mw->Photo( -data => encode_base64( get_photo() ), -format => "jpeg" ) ); my $time = localtime; $datelabel->configure( -text => $time ); } ); MainLoop;
      Thanks for that but I need it to talk to the webcam itself (it has no url)...
      David
Re: perly webcam generic interface
by theorbtwo (Prior) on Jul 02, 2003 at 08:47 UTC

    If this is for Linux, I'd point you at Video::Capture::V4l (I've looked at it, but havn't done anything complex with it.)

    If this is for win32, I'd recommend using fwink. (Which has nothing to do with perl, though I use it with my camnet script (which is too ugly to post, and does no actualy camera manipulation -- it just sends and displays jpegs.))


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).