Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Friends

firevision::V4L2Camera Class Reference

Video4Linux 2 camera access implementation. More...

#include <>>

Inheritance diagram for firevision::V4L2Camera:
Inheritance graph
[legend]

List of all members.

Classes

struct  ControlParameterInt
struct  FrameBuffer

Public Member Functions

 V4L2Camera (const char *device_name="/dev/video0")
 Constructor.
 V4L2Camera (const CameraArgumentParser *cap)
 Constructor.
virtual ~V4L2Camera ()
 Destructor.
virtual void open ()
virtual void start ()
virtual void stop ()
virtual void close ()
virtual void flush ()
virtual void capture ()
virtual void print_info ()
virtual bool ready ()
virtual unsigned char * buffer ()
virtual unsigned int buffer_size ()
virtual void dispose_buffer ()
virtual unsigned int pixel_width ()
virtual unsigned int pixel_height ()
virtual colorspace_t colorspace ()
virtual fawkes::Timecapture_time ()
virtual void set_image_number (unsigned int n)
virtual bool auto_gain ()
virtual void set_auto_gain (bool enabled)
virtual bool auto_white_balance ()
virtual void set_auto_white_balance (bool enabled)
virtual bool auto_exposure ()
virtual void set_auto_exposure (bool enabled)
virtual int red_balance ()
virtual void set_red_balance (int red_balance)
virtual int blue_balance ()
virtual void set_blue_balance (int blue_balance)
virtual int u_balance ()
virtual void set_u_balance (int u_balance)
virtual int v_balance ()
virtual void set_v_balance (int v_balance)
virtual unsigned int brightness ()
virtual void set_brightness (unsigned int brightness)
virtual unsigned int contrast ()
virtual void set_contrast (unsigned int contrast)
virtual unsigned int saturation ()
virtual void set_saturation (unsigned int saturation)
virtual int hue ()
virtual void set_hue (int hue)
virtual unsigned int exposure ()
virtual void set_exposure (unsigned int exposure)
virtual unsigned int gain ()
virtual void set_gain (unsigned int gain)
virtual const char * format ()
 Get the image format the camera currently uses.
virtual void set_format (const char *format)
 Set the image format the camera should use.
virtual unsigned int width ()
 Get the current width of the image.
virtual unsigned int height ()
 Get the current height of the image.
virtual void set_size (unsigned int width, unsigned int height)
 Set the image size the camera should use.
virtual bool horiz_mirror ()
 Return whether the camera image is horizontally mirrored.
virtual bool vert_mirror ()
 Return whether the camera image is vertically mirrored.
virtual void set_horiz_mirror (bool enabled)
 Set whether the camera should mirror images horizontally.
virtual void set_vert_mirror (bool enabled)
 Set whether the camera should mirror images vertically.
virtual unsigned int fps ()
 Get the number of frames per second that have been requested from the camera.
virtual void set_fps (unsigned int fps)
 Set the number of frames per second the camera tries to deliver.
virtual unsigned int lens_x_corr ()
 Get current lens x correction.
virtual unsigned int lens_y_corr ()
 Get current lens y correction.
virtual void set_lens_x_corr (unsigned int x_corr)
 Set lens x correction.
virtual void set_lens_y_corr (unsigned int y_corr)
 Set lens y correction.

Protected Member Functions

 V4L2Camera (const char *device_name, int dev)
 Protected Constructor.
virtual void set_one_control (const char *ctrl, unsigned int id, int value)
 Set one Camera control value.
virtual int get_one_control (const char *ctrl, unsigned int id)
 Get one Camera control value.

Protected Attributes

char * _device_name
 Device name.

Friends

class V4LCamera

Detailed Description

Video4Linux 2 camera access implementation.

Todo:

UPTR method

Standards queries (VIDIOC_ENUMSTD)

v4l2_pix_format.field

Author:
Tobias Kellner

Definition at line 46 of file v4l2.h.


Constructor & Destructor Documentation

firevision::V4L2Camera::V4L2Camera ( const char *  device_name = "/dev/video0"  ) 

Constructor.

Parameters:
device_name device file name (e.g. /dev/video0)

Definition at line 89 of file v4l2.cpp.

References _device_name.

firevision::V4L2Camera::V4L2Camera ( const CameraArgumentParser cap  ) 

Constructor.

Initialize camera with parameters from camera argument parser. Supported arguments: *Required:

  • device=DEV, device file, for example /dev/video0 (required) *Optional:
  • read_method=METHOD, preferred read method READ: read() MMAP: memory mapping UPTR: user pointer
  • format=FOURCC, preferred format
  • size=WIDTHxHEIGHT, preferred image size
  • switch_u_v=true/false, switch U and V channels
  • fps=FPS, frames per second
  • aec=true/false, Auto Exposition enabled [warning: only valid on nao]
  • awb=true/false, Auto White Balance enabled
  • agc=true/false, Auto Gain enabled
  • h_flip=true/false, Horizontal mirror
  • v_flip=true/false, Vertical mirror
  • brightness=BRIGHT, Brightness [0-255] (def. 128)
  • contrast=CONTR, Contrast [0-127] (def. 64)
  • saturation=SAT, Saturation [0-256] (def. 128)
  • hue=HUE, Hue [-180-180] (def. 0)
  • red_balance=RB, Red Balance [0-255] (def. 128)
  • blue_balance=BB, Blue Balance [0-255] (def. 128)
  • exposure=EXP, Exposure [0-65535] (def. 60)
  • gain=GAIN, Gain [0-255] (def. 0)
  • lens_x=CORR, Lens Correction X [0-255] (def. 0)
  • lens_y=CORR, Lens Correction Y [0-255] (def. 0)
    Parameters:
    cap camera argument parser

Definition at line 139 of file v4l2.cpp.

References _device_name, firevision::CameraArgumentParser::get(), firevision::CameraArgumentParser::has(), and firevision::CameraControlImage::size().

firevision::V4L2Camera::~V4L2Camera (  )  [virtual]

Destructor.

Definition at line 421 of file v4l2.cpp.

References _device_name.

firevision::V4L2Camera::V4L2Camera ( const char *  device_name,
int  dev 
) [protected]

Protected Constructor.

Gets called from V4LCamera, when the device has already been opened and determined to be a V4L2 device.

Parameters:
device_name device file name (e.g. /dev/video0)
dev file descriptor of the opened device

Definition at line 390 of file v4l2.cpp.

References _device_name.


Member Function Documentation

const char * firevision::V4L2Camera::format (  )  [virtual]

Get the image format the camera currently uses.

Check implementation documentation for details on the format.

Returns:
a string describing the image format
Exceptions:
NotImplementedException Not implemented by this control

Reimplemented from firevision::CameraControlImage.

Definition at line 1472 of file v4l2.cpp.

unsigned int firevision::V4L2Camera::fps (  )  [virtual]

Get the number of frames per second that have been requested from the camera.

A return value of 0 means that fps haven't been set yet through the camera.

Returns:
the currently requested fps or 0 if not set yet

Reimplemented from firevision::CameraControlImage.

Definition at line 1537 of file v4l2.cpp.

int firevision::V4L2Camera::get_one_control ( const char *  ctrl,
unsigned int  id 
) [protected, virtual]

Get one Camera control value.

Parameters:
ctrl name of the value
id ID of the value
Returns:
current value

Definition at line 860 of file v4l2.cpp.

Referenced by firevision::NaoCamera::auto_exposure(), horiz_mirror(), lens_x_corr(), lens_y_corr(), and vert_mirror().

unsigned int firevision::V4L2Camera::height (  )  [virtual]

Get the current height of the image.

Returns:
height in pixels

Implements firevision::CameraControlImage.

Definition at line 1492 of file v4l2.cpp.

bool firevision::V4L2Camera::horiz_mirror (  )  [virtual]

Return whether the camera image is horizontally mirrored.

Returns:
true if the image is horizontally mirrored
Exceptions:
NotImplementedException Not implemented by this control

Reimplemented from firevision::CameraControlImage.

Definition at line 1507 of file v4l2.cpp.

References get_one_control().

unsigned int firevision::V4L2Camera::lens_x_corr (  )  [virtual]

Get current lens x correction.

Returns:
current lens x correction
Exceptions:
NotImplementedException Not implemented by this control

Reimplemented from firevision::CameraControlImage.

Definition at line 1550 of file v4l2.cpp.

References get_one_control().

unsigned int firevision::V4L2Camera::lens_y_corr (  )  [virtual]

Get current lens y correction.

Returns:
current lens y correction
Exceptions:
NotImplementedException Not implemented by this control

Reimplemented from firevision::CameraControlImage.

Definition at line 1556 of file v4l2.cpp.

References get_one_control().

void firevision::V4L2Camera::set_format ( const char *  format  )  [virtual]

Set the image format the camera should use.

Check implementation documentation for details on the format.

Parameters:
format the new image format
Exceptions:
NotImplementedException Not implemented by this control

Reimplemented from firevision::CameraControlImage.

Definition at line 1478 of file v4l2.cpp.

void firevision::V4L2Camera::set_fps ( unsigned int  fps  )  [virtual]

Set the number of frames per second the camera tries to deliver.

Parameters:
fps the new fps
Exceptions:
NotImplementedException Not implemented by this control

Reimplemented from firevision::CameraControlImage.

Definition at line 1543 of file v4l2.cpp.

References set_fps().

Referenced by set_fps().

void firevision::V4L2Camera::set_horiz_mirror ( bool  enabled  )  [virtual]

Set whether the camera should mirror images horizontally.

Parameters:
enabled if true, images should be mirrored horizontally
Exceptions:
NotImplementedException Not implemented by this control

Reimplemented from firevision::CameraControlImage.

Definition at line 1519 of file v4l2.cpp.

References set_one_control().

void firevision::V4L2Camera::set_lens_x_corr ( unsigned int  x_corr  )  [virtual]

Set lens x correction.

Parameters:
x_corr new lens x correction
Exceptions:
NotImplementedException Not implemented by this control

Reimplemented from firevision::CameraControlImage.

Definition at line 1562 of file v4l2.cpp.

References set_one_control().

void firevision::V4L2Camera::set_lens_y_corr ( unsigned int  y_corr  )  [virtual]

Set lens y correction.

Parameters:
y_corr new lens y correction
Exceptions:
NotImplementedException Not implemented by this control

Reimplemented from firevision::CameraControlImage.

Definition at line 1569 of file v4l2.cpp.

References set_one_control().

void firevision::V4L2Camera::set_one_control ( const char *  ctrl,
unsigned int  id,
int  value 
) [protected, virtual]

Set one Camera control value.

Parameters:
ctrl name of the value
id ID of the value
value value to set

Definition at line 817 of file v4l2.cpp.

Referenced by firevision::NaoCamera::set_auto_exposure(), set_horiz_mirror(), set_lens_x_corr(), set_lens_y_corr(), and set_vert_mirror().

void firevision::V4L2Camera::set_size ( unsigned int  width,
unsigned int  height 
) [virtual]

Set the image size the camera should use.

Parameters:
width new width of the image
height new height of the image
Exceptions:
Exception thrown for instance if size setting at run-time is not supported

Implements firevision::CameraControlImage.

Definition at line 1498 of file v4l2.cpp.

void firevision::V4L2Camera::set_vert_mirror ( bool  enabled  )  [virtual]

Set whether the camera should mirror images vertically.

Parameters:
enabled if true, images should be mirrored vertically
Exceptions:
NotImplementedException Not implemented by this control

Reimplemented from firevision::CameraControlImage.

Definition at line 1526 of file v4l2.cpp.

References set_one_control().

bool firevision::V4L2Camera::vert_mirror (  )  [virtual]

Return whether the camera image is vertically mirrored.

Returns:
true if the image is vertically mirrored
Exceptions:
NotImplementedException Not implemented by this control

Reimplemented from firevision::CameraControlImage.

Definition at line 1513 of file v4l2.cpp.

References get_one_control().

unsigned int firevision::V4L2Camera::width (  )  [virtual]

Get the current width of the image.

Returns:
width in pixels

Implements firevision::CameraControlImage.

Definition at line 1486 of file v4l2.cpp.


Member Data Documentation

Device name.

Definition at line 138 of file v4l2.h.

Referenced by firevision::NaoCamera::NaoCamera(), firevision::NaoCamera::set_source(), V4L2Camera(), and ~V4L2Camera().


The documentation for this class was generated from the following files: