Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

v4l2capture.h File Reference


Detailed Description

set of functions to grab frames from v4l2 device

This is a very light wrapper to v4l2 interface. It uses MMAP transfer method only and doesn't do any copying, just passing assigned buffers filled by driver. It's intention was to easily access device without need to prepate all those structures for ioctl's.

To use it, first create FRAMEGRABBER2 object by fg2_createFrameGrabber

Authors
Marcin Rudowski

Definition in file v4l2capture.h.

#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <asm/types.h>
#include <linux/videodev.h>

Go to the source code of this file.

Classes

struct  my_buffer
struct  FRAMEGRABBER2

Defines

#define FG_DEFAULT_DEVICE   "/dev/video0"
#define FG_DEFAULT_WIDTH   640
#define FG_DEFAULT_HEIGHT   480
#define FG_SOURCE_TV   0
#define FG_SOURCE_COMPOSITE   1
#define FG_SOURCE_SVIDEO   2

Functions

FRAMEGRABBER2fg2_createFrameGrabber ()
void fg2_delete (FRAMEGRABBER2 **fg)
int fg2_open (FRAMEGRABBER2 *fg, const char *dev)
int fg2_startCapture (FRAMEGRABBER2 *fg)
int fg2_stopCapture (FRAMEGRABBER2 *fg)
my_buffergetFrameBuffer (FRAMEGRABBER2 *fg)
void giveBackFrameBuffer (FRAMEGRABBER2 *fg, struct my_buffer *mBuff)
int fg2_get_source_count (FRAMEGRABBER2 *fg)
int fg2_get_source_id (FRAMEGRABBER2 *fg)
const char * fg2_get_source_name (FRAMEGRABBER2 *fg)
const char * fg2_get_id_source_name (FRAMEGRABBER2 *fg, int src)
const char * fg2_get_device_name (FRAMEGRABBER2 *fg)
int fg2_set_source (FRAMEGRABBER2 *fg, int src, const char *strSrc)
int fg2_countControls (FRAMEGRABBER2 *fg)
int fg2_setControlValueI (FRAMEGRABBER2 *fg, int id, double val)
int fg2_setControlValue (FRAMEGRABBER2 *fg, const char *id, double val)
double fg2_getControlValueI (FRAMEGRABBER2 *fg, int id)
double fg2_getControlValue (FRAMEGRABBER2 *fg, const char *id)
const char * fg2_getControlName (FRAMEGRABBER2 *fg, int id)
int fg2_set_source_norm (FRAMEGRABBER2 *fg, v4l2_std_id norm)
int fg2_setPixelSettings (FRAMEGRABBER2 *fg, int width, int height, unsigned int fmt, enum v4l2_field fld, int depth)


Function Documentation

int fg2_countControls FRAMEGRABBER2 fg  ) 
 

Returns number of found controls

Definition at line 464 of file v4l2capture.c.

References FRAMEGRABBER2::numOfCtls.

FRAMEGRABBER2* fg2_createFrameGrabber  ) 
 

Create device handler (just fill structure)

Returns:
new device handler

Definition at line 90 of file v4l2capture.c.

References FRAMEGRABBER2::altField, FRAMEGRABBER2::buffers, FRAMEGRABBER2::controls, FRAMEGRABBER2::cur_frame, FRAMEGRABBER2::device, FRAMEGRABBER2::fd, FRAMEGRABBER2::field, FRAMEGRABBER2::height, FRAMEGRABBER2::isCapturing, FRAMEGRABBER2::n_buffers, FRAMEGRABBER2::numOfCtls, FRAMEGRABBER2::numOfIn, FRAMEGRABBER2::pix_fmt, FRAMEGRABBER2::source, FRAMEGRABBER2::sources, and FRAMEGRABBER2::width.

void fg2_delete FRAMEGRABBER2 **  fg  ) 
 

delete completely fg handler (including whatever is needed to close device)

Parameters:
fg 

Definition at line 126 of file v4l2capture.c.

const char* fg2_get_device_name FRAMEGRABBER2 fg  ) 
 

Name of device

Definition at line 409 of file v4l2capture.c.

References FRAMEGRABBER2::caps.

const char* fg2_get_id_source_name FRAMEGRABBER2 fg,
int  src
 

Name of given source identified by id

Definition at line 395 of file v4l2capture.c.

References FRAMEGRABBER2::numOfIn, and FRAMEGRABBER2::sources.

int fg2_get_source_count FRAMEGRABBER2 fg  ) 
 

Returns number of found inputs

Definition at line 364 of file v4l2capture.c.

References FRAMEGRABBER2::numOfIn.

int fg2_get_source_id FRAMEGRABBER2 fg  ) 
 

Current source id

Definition at line 372 of file v4l2capture.c.

References FRAMEGRABBER2::fd.

const char* fg2_get_source_name FRAMEGRABBER2 fg  ) 
 

Current source name

Definition at line 387 of file v4l2capture.c.

double fg2_getControlValue FRAMEGRABBER2 fg,
const char *  id
 

Gets current control value. <0 means error. Control is identified by its name

Definition at line 560 of file v4l2capture.c.

References FRAMEGRABBER2::controls, and FRAMEGRABBER2::numOfCtls.

double fg2_getControlValueI FRAMEGRABBER2 fg,
int  id
 

Gets current control value. <0 means error. Control is identified by id in local table

Definition at line 531 of file v4l2capture.c.

References FRAMEGRABBER2::controls, FRAMEGRABBER2::fd, and FRAMEGRABBER2::numOfCtls.

int fg2_open FRAMEGRABBER2 fg,
const char *  dev
 

open device and discover capabilities and inputs. To capture from device You need to use fg2_startCapture first. Earlier You can set source and size.

Parameters:
fg framegrabber handler
dev pathc to /dev/videoX file
Returns:
error status

Definition at line 140 of file v4l2capture.c.

References FRAMEGRABBER2::caps, FRAMEGRABBER2::cur_frame, FRAMEGRABBER2::device, FRAMEGRABBER2::fd, FG_DEFAULT_DEVICE, and FRAMEGRABBER2::numOfIn.

int fg2_set_source FRAMEGRABBER2 fg,
int  srcNo,
const char *  strSrc
 

Select input source. if src<0, then strSrc is used to compare with known sources

Returns:
error status

Definition at line 419 of file v4l2capture.c.

References FRAMEGRABBER2::fd, FRAMEGRABBER2::numOfIn, FRAMEGRABBER2::source, and FRAMEGRABBER2::sources.

int fg2_set_source_norm FRAMEGRABBER2 fg,
v4l2_std_id  norm
 

pal, ntsc, secam, etc.

Definition at line 586 of file v4l2capture.c.

References FRAMEGRABBER2::fd.

int fg2_setControlValue FRAMEGRABBER2 fg,
const char *  id,
double  val
 

Sets new value to control. Val is in 0.0-1.0 range. Values <0 means use default Control is identified by its name

Definition at line 516 of file v4l2capture.c.

References FRAMEGRABBER2::controls, and FRAMEGRABBER2::numOfCtls.

int fg2_setControlValueI FRAMEGRABBER2 fg,
int  id,
double  val
 

Sets new value to control. Val is in 0.0-1.0 range. Values <0 means use default Control is identified by id in local table

Definition at line 473 of file v4l2capture.c.

References FRAMEGRABBER2::controls, FRAMEGRABBER2::fd, and FRAMEGRABBER2::numOfCtls.

int fg2_setPixelSettings FRAMEGRABBER2 fg,
int  width,
int  height,
unsigned int  fmt,
enum v4l2_field  fld,
int  dpth
 

Tries to apply given frame settings

Definition at line 603 of file v4l2capture.c.

References FRAMEGRABBER2::depth, FRAMEGRABBER2::field, FRAMEGRABBER2::height, FRAMEGRABBER2::pix_fmt, and FRAMEGRABBER2::width.

int fg2_startCapture FRAMEGRABBER2 fg  ) 
 

Turn capture stream on. You need to use it by hand after opening, or stopping

Returns:
error status

Definition at line 217 of file v4l2capture.c.

References FRAMEGRABBER2::fd, and FRAMEGRABBER2::isCapturing.

int fg2_stopCapture FRAMEGRABBER2 fg  ) 
 

Turn capture stream of. You need to use it by hand when changing format or size of frame. Only controls doesn't need stopping

Returns:
error status

Definition at line 268 of file v4l2capture.c.

References FRAMEGRABBER2::fd, and FRAMEGRABBER2::isCapturing.

struct my_buffer* getFrameBuffer FRAMEGRABBER2 fg  ) 
 

light capture interface, gives live data without any memcpy (just after dequeueing)

Parameters:
fg framegrabber struct
Returns:
bufer struct (dont change it, just read)

Definition at line 300 of file v4l2capture.c.

References FRAMEGRABBER2::altField, my_buffer::buf, FRAMEGRABBER2::buffers, FRAMEGRABBER2::fd, and FRAMEGRABBER2::n_buffers.

void giveBackFrameBuffer FRAMEGRABBER2 fg,
struct my_buffer mBuff
 

This is opposite to getFrameBuffer. It Queues used buffer to the driver.

Parameters:
fg framegrabber handler
mBuff earlier received buffer with image and its state

Definition at line 347 of file v4l2capture.c.

References my_buffer::buf, and FRAMEGRABBER2::fd.


Generated on Thu Jun 29 22:04:43 2006 for Camerav4l2 by  doxygen 1.4.4