Re: Video frame grabbing



Hi Frank,

Frank Hrebabetzky wrote:
> I want to transfer image frames (640x480x8 gray values) from the video
> device to a gtk pixmap. I understood the data stucture underlying
> pixmap, but I never accessed a device.

On linux, you should use the video4linux system. This is a standard(ish) API
which you can use to talk to most linux video devices.

http://www.exploits.org/v4l/

For source examples, I'd suggest looking at the insides of some of the linux
webcam programs, they're all really simple and do almost exactly what you
want. 

Here's a thing I did for single-frame linux video grabs. It probably ought
to be redone for v4l2:

  http://cima.ng-london.org.uk/~john/im_video_v4l1.c
  http://cima.ng-london.org.uk/~john/im_video_v4l1.h

Use it something like this:

grab_frame( IMAGE *im, const char *device,
	int channel, int brightness, int colour, int contrast, int hue, 
	int ngrabs )
{
	LGrab *lg;

	if( !(lg = lgrab_new( device )) )
		return( -1 );

	if( lgrab_set_capture_size( lg, 
		lg->capability.maxwidth, lg->capability.maxheight ) ||
		lgrab_set_channel( lg, channel ) ||
		lgrab_set_brightness( lg, brightness ) ||
		lgrab_set_colour( lg, colour ) ||
		lgrab_set_contrast( lg, contrast ) ||
		lgrab_set_hue( lg, hue ) ||
		lgrab_set_ngrabs( lg, ngrabs ) ||
		lgrab_capture( lg, im ) ) {
		lgrab_destroy( lg );
		return( -1 );
	}

	lgrab_destroy( lg );

	return( 0 );
}

John



========================================================== 

Current Exhibition: 

T I T I A N 

Until 18 May 2003 

Advance Booking Recommended 
Open every day 
Wed-Sat late opening until 9pm 

For information and tickets: 
http://www.nationalgallery.org.uk/exhibitions/titian



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]