Hi, yesterday a question intrigued me about accessing a video camera directly and saving pictures. Well I went and downloaded Video-Capture-V4l-0.222 from http://cpan.org and started playing with it. As a comparison, I also played with a simple c program called videodog which does a nice job of saving in raw,pnm,or jpg formats.

Now for the perl question. The code below seems to capture raw frames, can anyone point me in the right direction on how to save them as pnm or jpg? The doc in the VideoCapture module are not too clear to me.

#!/usr/bin/perl use Video::Capture::V4l; sub print_picture { my $c=shift; print "Picture Settings: "; print "brightness ",$c->brightness; print ", hue ",$c->hue; print ", colour ",$c->colour; print ", contrast ",$c->contrast; print ", whiteness ",$c->whiteness; print ", depth ",$c->depth; print ", palette ",$c->palette; print "\n"; } $grab = new Video::Capture::V4l or die "Unable to open Videodevice: $!"; print_picture $grab->picture; $|=1; my $frame=0; my $fr=$grab->capture ($frame, 640, 480); my $count=0; for(1..2) { my $nfr = $grab->capture (1-$frame, 640, 480); $grab->sync($frame) or die "unable to sync"; # save $fr now, as it contains the raw BGR data open (JP,">z$count.raw") or die $!; print JP $nfr; close JP; print "."; $count++; $frame = 1-$frame; $fr = $nfr; }

In reply to capturing raw video with v4l by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.