Fawkes API  Fawkes Development Version
firevision::V4LCamera Class Reference

#include <>>

Inheritance diagram for firevision::V4LCamera:

Public Member Functions

 V4LCamera (const char *device_name="/dev/video0")
 Constructor. More...
 
 V4LCamera (const CameraArgumentParser *cap)
 Constructor. More...
 
virtual ~V4LCamera ()
 Destructor. More...
 
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 void set_image_number (unsigned int n)
 
- Public Member Functions inherited from firevision::Camera
virtual ~Camera ()
 Virtual empty destructor. More...
 
virtual fawkes::Timecapture_time ()
 Get the Time of the last successfully captured image. More...
 

Detailed Description

General Video4Linux camera implementation. Maintains backwards compatibility. Chooses on the fly whether v4l1 or v4l2 is needed for a given device.

Author
Tobias Kellner

Definition at line 40 of file v4l.h.

Constructor & Destructor Documentation

◆ V4LCamera() [1/2]

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

Constructor.

Parameters
device_namedevice file name (e.g. /dev/video0)

Definition at line 63 of file v4l.cpp.

References firevision::CameraArgumentParser::get(), and firevision::CameraArgumentParser::has().

◆ V4LCamera() [2/2]

firevision::V4LCamera::V4LCamera ( const CameraArgumentParser cap)

Constructor.

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

  • device=DEV, device file, for example /dev/video0
    Parameters
    capcamera argument parser

Definition at line 75 of file v4l.cpp.

◆ ~V4LCamera()

firevision::V4LCamera::~V4LCamera ( )
virtual

Destructor.

Definition at line 85 of file v4l.cpp.

References open().

Member Function Documentation

◆ buffer()

unsigned char * firevision::V4LCamera::buffer ( )
virtual

Get access to current image buffer. This will return a pointer to the current buffer. The buffer contains an image of the given colorspace, width and height.

Returns
pointer to image buffer

Implements firevision::Camera.

Definition at line 180 of file v4l.cpp.

References firevision::Camera::buffer_size().

◆ buffer_size()

unsigned int firevision::V4LCamera::buffer_size ( )
virtual

Size of buffer. Gets the size in bytes of the buffer returned by buffer().

Returns
size of buffer in bytes

Implements firevision::Camera.

Definition at line 186 of file v4l.cpp.

References firevision::Camera::dispose_buffer().

◆ capture()

void firevision::V4LCamera::capture ( )
virtual

Capture an image. Although cameras shall operate with a continuous image flow where possible sometimes capturing an image means copying a buffer or advancing a buffer list pointer. This shall be done in this method. For a camera-using application it is mandatory to call capture() just before accessing the image buffer.

Implements firevision::Camera.

Definition at line 160 of file v4l.cpp.

References firevision::Camera::print_info().

◆ close()

void firevision::V4LCamera::close ( )
virtual

Close camera. This closes the camera device. The camera must have been stopped before calling close().

Implements firevision::Camera.

Definition at line 146 of file v4l.cpp.

References firevision::Camera::flush().

◆ colorspace()

colorspace_t firevision::V4LCamera::colorspace ( )
virtual

Colorspace of returned image.

Returns
colorspace of image returned by buffer()

Implements firevision::Camera.

Definition at line 217 of file v4l.cpp.

References firevision::Camera::set_image_number().

◆ dispose_buffer()

void firevision::V4LCamera::dispose_buffer ( )
virtual

Dispose current buffer. Some cameras need disposal of the current buffer (for example to free space in a queue to retrieve the next image). This is done with this method. It has to be called after all work has been done on the image as desired. After dispose_buffer() has been called no further access may happen to the image buffer or undesired behavior may happen.

Implements firevision::Camera.

Definition at line 192 of file v4l.cpp.

References firevision::Camera::pixel_width().

◆ flush()

void firevision::V4LCamera::flush ( )
virtual

Flush image queue. Some cameras may have an image buffer queue. With this it can happen that if the processing of an image took longer than desired it is needed to flush this buffer queue.

Implements firevision::Camera.

Definition at line 153 of file v4l.cpp.

References firevision::Camera::capture().

◆ open()

void firevision::V4LCamera::open ( )
virtual

Open the camera. The camera is opened, but image transfer not yet started. This can be used to detect general problems with the camera while delaying the real transfer startup until it is needed.

Implements firevision::Camera.

Definition at line 93 of file v4l.cpp.

Referenced by ~V4LCamera().

◆ pixel_height()

unsigned int firevision::V4LCamera::pixel_height ( )
virtual

Height of image in pixels.

Returns
height of image in pixels

Implements firevision::Camera.

Definition at line 208 of file v4l.cpp.

◆ pixel_width()

unsigned int firevision::V4LCamera::pixel_width ( )
virtual

Width of image in pixels.

Returns
width of image in pixels

Implements firevision::Camera.

Definition at line 199 of file v4l.cpp.

◆ print_info()

void firevision::V4LCamera::print_info ( )
virtual

Print out camera information. Shall print out camera information and current setup information on stdout.

Implements firevision::Camera.

Definition at line 167 of file v4l.cpp.

References firevision::Camera::ready().

◆ ready()

bool firevision::V4LCamera::ready ( )
virtual

Camera is ready for taking pictures. The camera has been opened and started correctly and may now provide images.

Returns
true, if the camera is ready, false otherwise

Implements firevision::Camera.

Definition at line 174 of file v4l.cpp.

References firevision::Camera::buffer().

◆ set_image_number()

void firevision::V4LCamera::set_image_number ( unsigned int  n)
virtual

Set image number to retrieve. If a camera is able to retrieve several images this method can be used to select the image to be retrieved with the next call to capture().

Parameters
nimage number to set

Implements firevision::Camera.

Definition at line 223 of file v4l.cpp.

◆ start()

void firevision::V4LCamera::start ( )
virtual

Start image transfer from the camera. For many cameras opening the camera and starting transmission of images are two tasks. This method will simply initiate the transfer after the camera as been opened. And exception shall be thrown if the camera has not been opened.

Implements firevision::Camera.

Definition at line 128 of file v4l.cpp.

◆ stop()

void firevision::V4LCamera::stop ( )
virtual

Stop image transfer from the camera. This will stop the image transfer initiated with start(). This can be used to start and stop the image transfer at will without opening and closing operations inbetween.

Implements firevision::Camera.

Definition at line 137 of file v4l.cpp.


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