Video::Capture example?

S

Stan Brown

I'm writing a perl script to capture images from some cameras, and make
mpes out of them on Linux.

I't basicly working using system() calls to v4lctl, but that is slowing
things dow, spawning a seperate task for each capture.

I've found the Video::Captur module, and I think it's the way to go.
However it has no documentation for the calls, and the example programs
have no comments.

Could anyone point me to a working example of capturing an image using
this? I suspect I jyst need to traslate a couple of v4;ctl commands to the
corect syntax for using this module. EG:

system("/usr/bin/v4lctl -c $::config{video_dev} setinput $::config{video_type}");

and:

system("/usr/bin/v4lctl -c $::config{video_dev} snap jpeg 640x480 $tmpfile");



Any pointers to examples would be appreciated.
 
S

Stan Brown

Here is a Tk camera capture program is wrote. The biggest obstacles are
making sure the camera syncs, and converting the raw BGR data to RGB.
There are a couple of different ways you can do this, I used a technique
of reversing the data, then flipping it with Imager. Imager also has a
more direct matrix method, but I think it was a bit slower that way.
Read "perldoc Imager::Transformations".

Thanks for this.m It looks like it will help a lot

Sorry I missed it earlier :-(
 
S

Stan Brown

Here is a Tk camera capture program is wrote. The biggest obstacles are
making sure the camera syncs, and converting the raw BGR data to RGB.
There are a couple of different ways you can do this, I used a technique
of reversing the data, then flipping it with Imager. Imager also has a
more direct matrix method, but I think it was a bit slower that way.
Read "perldoc Imager::Transformations".


Thanks for the help on this again!

I've managed to integrate major peices of this into my script, and have it
working! But I've got a few questiosn, if some kind soul could enlighten me
a bit further.

First, why do we go through the capture/convert loop twice per grab?

for ( 0 .. 1 ) {
my $nfr = $grab->capture( 1 - $frame, 640, 480 );

I've been benchmarking, and it seems that the 2nd pass take much longer
than the first.

second, could someone explain these calls to me?

my $channel = $grab->channel(0);
my $tuner = $grab->tuner(0);
$tuner->mode(1);
$channel->norm(1);
$tuner->set;
$channel->set;

It appears to me that first read the chanlel (and tuner ? what's a tuner?)
The set them back?

And finally, if I want to use the 2nd capture card, I pass a 1 to the first
2 calls, right?

Thansk again for all the help on this!
 
S

Stan Brown

Well the short version is, I have no idea how to make Videp::Capture use
the 2nd card (/dev/video1). I suppose it hase to do with the new
Video::Capture::V4l to create a new object. But with no docs, I could be
guessing for a while :-(

Anyone know the magic incatation Here?

And nowing what magic numers to pass to what set-> routine to get composite
video would be useful too.
 
S

Stan Brown

Try it without it and see what happens. It is a mystery to me too.
It seems to have something with getting a sync for the image.

Thanks for the help on this!


My biggest remaining issue is geting this to support the 2nd card. I posted
a message about this in a new thread. I found the call to new in the
module, and the device is optionaly the 2nd argument. Problem is I don't
now what to pass for the first "class" argument.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top