Fawkes API
Fawkes Development Version
|
Video4Linux 2 camera access implementation. More...
#include <>>
Public Member Functions | |
V4L2Camera (const char *device_name="/dev/video0") | |
Constructor. More... | |
V4L2Camera (const CameraArgumentParser *cap) | |
Constructor. More... | |
virtual | ~V4L2Camera () |
Destructor. More... | |
virtual void | open () |
Open the camera. More... | |
virtual void | start () |
Start image transfer from the camera. More... | |
virtual void | stop () |
Stop image transfer from the camera. More... | |
virtual void | close () |
Close camera. More... | |
virtual void | flush () |
Flush image queue. More... | |
virtual void | capture () |
Capture an image. More... | |
virtual void | print_info () |
Print out camera information. More... | |
virtual bool | ready () |
Camera is ready for taking pictures. More... | |
virtual unsigned char * | buffer () |
Get access to current image buffer. More... | |
virtual unsigned int | buffer_size () |
Size of buffer. More... | |
virtual void | dispose_buffer () |
Dispose current buffer. More... | |
virtual unsigned int | pixel_width () |
Width of image in pixels. More... | |
virtual unsigned int | pixel_height () |
Height of image in pixels. More... | |
virtual colorspace_t | colorspace () |
Colorspace of returned image. More... | |
virtual fawkes::Time * | capture_time () |
Get the Time of the last successfully captured image. More... | |
virtual void | set_image_number (unsigned int n) |
Set image number to retrieve. More... | |
virtual bool | auto_gain () |
Return whether auto gain is enabled. More... | |
virtual void | set_auto_gain (bool enabled) |
Enable/disable auto gain. More... | |
virtual bool | auto_white_balance () |
Return whether auto white balance is enabled. More... | |
virtual void | set_auto_white_balance (bool enabled) |
Enable/disable auto white balance. More... | |
virtual unsigned int | exposure_auto () |
Return whether auto exposure is enabled. More... | |
virtual void | set_exposure_auto (unsigned int exposure_auto) |
Enable/disable auto exposure. More... | |
virtual int | red_balance () |
Get current red balance. More... | |
virtual void | set_red_balance (int red_balance) |
Set red balance. More... | |
virtual int | blue_balance () |
Get current blue balance. More... | |
virtual void | set_blue_balance (int blue_balance) |
Set blue balance. More... | |
virtual int | u_balance () |
Get current u balance. More... | |
virtual void | set_u_balance (int u_balance) |
Set u balance. More... | |
virtual int | v_balance () |
Get current v balance. More... | |
virtual void | set_v_balance (int v_balance) |
Set v balance. More... | |
virtual unsigned int | brightness () |
Get current brightness. More... | |
virtual void | set_brightness (unsigned int brightness) |
Set new brightness. More... | |
virtual unsigned int | contrast () |
Get current contrast. More... | |
virtual void | set_contrast (unsigned int contrast) |
Set new contrast. More... | |
virtual unsigned int | saturation () |
Get current saturation. More... | |
virtual void | set_saturation (unsigned int saturation) |
Set new saturation. More... | |
virtual int | hue () |
Get current hue. More... | |
virtual void | set_hue (int hue) |
Set new hue. More... | |
virtual unsigned int | exposure () |
Get current exposure. More... | |
virtual void | set_exposure (unsigned int exposure) |
Set new exposure. More... | |
virtual unsigned int | gain () |
Get current gain. More... | |
virtual void | set_gain (unsigned int gain) |
Set new gain. More... | |
virtual const char * | format () |
Get the image format the camera currently uses. More... | |
virtual void | set_format (const char *format) |
Set the image format the camera should use. More... | |
virtual unsigned int | width () |
Get the current width of the image. More... | |
virtual unsigned int | height () |
Get the current height of the image. More... | |
virtual void | set_size (unsigned int width, unsigned int height) |
Set the image size the camera should use. More... | |
virtual bool | horiz_mirror () |
Return whether the camera image is horizontally mirrored. More... | |
virtual bool | vert_mirror () |
Return whether the camera image is vertically mirrored. More... | |
virtual void | set_horiz_mirror (bool enabled) |
Set whether the camera should mirror images horizontally. More... | |
virtual void | set_vert_mirror (bool enabled) |
Set whether the camera should mirror images vertically. More... | |
virtual unsigned int | fps () |
Get the number of frames per second that have been requested from the camera. More... | |
virtual void | set_fps (unsigned int fps) |
Set the number of frames per second the camera tries to deliver. More... | |
virtual unsigned int | lens_x_corr () |
Get current lens x correction. More... | |
virtual unsigned int | lens_y_corr () |
Get current lens y correction. More... | |
virtual void | set_lens_x_corr (unsigned int x_corr) |
Set lens x correction. More... | |
virtual void | set_lens_y_corr (unsigned int y_corr) |
Set lens y correction. More... | |
virtual bool | exposure_auto_priority () |
Get exposure_auto_priority V4L2 control. More... | |
virtual void | set_exposure_auto_priority (bool enabled) |
Set exposure_auto_priority V4L2 control. More... | |
virtual unsigned int | white_balance_temperature () |
Get absolute white balance setting. More... | |
virtual void | set_white_balance_temperature (unsigned int white_balance_temperature) |
Set white balance. More... | |
virtual unsigned int | exposure_absolute () |
Get absolute exposure time. More... | |
virtual void | set_exposure_absolute (unsigned int exposure_absolute) |
set absolute exposure time (1/s) More... | |
virtual unsigned int | sharpness () |
Get sharpness value. More... | |
virtual void | set_sharpness (unsigned int sharpness) |
Set sharpness. More... | |
![]() | |
virtual | ~Camera () |
Virtual empty destructor. More... | |
![]() | |
virtual | ~CameraControlColor () |
Empty virtual destructor. More... | |
virtual void | set_auto_all (bool enabled) |
Enable/disable all automatic settings. More... | |
![]() | |
virtual | ~CameraControl () |
Virtual empty destructor. More... | |
![]() | |
virtual | ~CameraControlImage () |
Empty virtual destructor. More... | |
virtual void | size (unsigned int &width, unsigned int &height) |
Get the current image size. More... | |
virtual void | mirror (bool &horiz, bool &vert) |
Get information about current camera image mirroring. More... | |
virtual void | set_mirror (bool horiz, bool vert) |
Set whether the camera should mirror images. More... | |
virtual void | lens_corr (unsigned int &x_corr, unsigned int &y_corr) |
Get current lens correction. More... | |
virtual void | set_lens_corr (unsigned int x_corr, unsigned int y_corr) |
Set lens correction. More... | |
Protected Member Functions | |
V4L2Camera (const char *device_name, int dev) | |
Protected Constructor. More... | |
virtual void | set_one_control (const char *ctrl, unsigned int id, int value) |
Set one Camera control value. More... | |
virtual int | get_one_control (const char *ctrl, unsigned int id) |
Get one Camera control value. More... | |
Protected Attributes | |
char * | _device_name |
Device name. More... | |
Video4Linux 2 camera access implementation.
UPTR method
v4l2_pix_format.field
firevision::V4L2Camera::V4L2Camera | ( | const char * | device_name = "/dev/video0" | ) |
Constructor.
device_name | device file name (e.g. /dev/video0) |
Definition at line 83 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:
cap | camera argument parser |
Definition at line 141 of file v4l2.cpp.
References _device_name, firevision::CameraArgumentParser::get(), firevision::CameraArgumentParser::has(), and firevision::CameraControlImage::size().
|
virtual |
|
protected |
Protected Constructor.
Gets called from V4LCamera, when the device has already been opened and determined to be a V4L2 device.
device_name | device file name (e.g. /dev/video0) |
dev | file descriptor of the opened device |
Definition at line 364 of file v4l2.cpp.
References _device_name, and close().
|
virtual |
Return whether auto gain is enabled.
Implements firevision::CameraControlColor.
Definition at line 1403 of file v4l2.cpp.
References get_one_control().
|
virtual |
Return whether auto white balance is enabled.
Implements firevision::CameraControlColor.
Definition at line 1416 of file v4l2.cpp.
References get_one_control().
|
virtual |
Get current blue balance.
Implements firevision::CameraControlColor.
Definition at line 1455 of file v4l2.cpp.
References get_one_control().
Referenced by set_blue_balance().
|
virtual |
Get current brightness.
Implements firevision::CameraControlColor.
Definition at line 1492 of file v4l2.cpp.
References get_one_control().
Referenced by set_brightness().
|
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.
Implements firevision::Camera.
Definition at line 1216 of file v4l2.cpp.
Referenced by capture(), close(), dispose_buffer(), and start().
|
virtual |
Size of buffer.
Gets the size in bytes of the buffer returned by buffer().
Implements firevision::Camera.
Definition at line 1224 of file v4l2.cpp.
References firevision::CameraControlImage::size().
|
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 1162 of file v4l2.cpp.
References buffer(), close(), fawkes::Time::set_time(), firevision::CameraControlImage::size(), and fawkes::Time::stamp().
|
virtual |
Get the Time of the last successfully captured image.
Returns a Time representing the time when the last image was captured successfully. Note that calling this function is only valid after capture() and before dispose_buffer() has been called – it is only valid when an image is currently available.
NotImplementedException | thrown if Camera does not support time stamping |
Reimplemented from firevision::Camera.
|
virtual |
Close camera.
This closes the camera device. The camera must have been stopped before calling close().
Implements firevision::Camera.
Definition at line 1031 of file v4l2.cpp.
References buffer(), firevision::CameraControlImage::size(), and stop().
Referenced by capture(), dispose_buffer(), get_one_control(), open(), set_one_control(), start(), V4L2Camera(), and ~V4L2Camera().
|
virtual |
Colorspace of returned image.
Implements firevision::Camera.
|
virtual |
Get current contrast.
Implements firevision::CameraControlColor.
Definition at line 1505 of file v4l2.cpp.
References get_one_control().
Referenced by set_contrast().
|
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.
|
virtual |
Get current exposure.
Implements firevision::CameraControlColor.
Definition at line 1544 of file v4l2.cpp.
References get_one_control().
Referenced by set_exposure().
|
virtual |
Get absolute exposure time.
Definition at line 1365 of file v4l2.cpp.
References get_one_control().
Referenced by set_exposure_absolute().
|
virtual |
Return whether auto exposure is enabled.
Implements firevision::CameraControlColor.
Reimplemented in firevision::NaoCamera.
Definition at line 1429 of file v4l2.cpp.
References get_one_control().
Referenced by set_exposure_auto().
|
virtual |
Get exposure_auto_priority V4L2 control.
Definition at line 1317 of file v4l2.cpp.
References get_one_control().
|
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.
|
virtual |
Get the image format the camera currently uses.
Check implementation documentation for details on the format.
NotImplementedException | Not implemented by this control |
Reimplemented from firevision::CameraControlImage.
Definition at line 1570 of file v4l2.cpp.
Referenced by print_info(), and set_format().
|
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.
Reimplemented from firevision::CameraControlImage.
Definition at line 1635 of file v4l2.cpp.
Referenced by set_fps().
|
virtual |
Get current gain.
Implements firevision::CameraControlColor.
Definition at line 1557 of file v4l2.cpp.
References get_one_control().
Referenced by set_gain().
|
protectedvirtual |
Get one Camera control value.
ctrl | name of the value |
id | ID of the value |
Definition at line 903 of file v4l2.cpp.
References close().
Referenced by auto_gain(), auto_white_balance(), blue_balance(), brightness(), contrast(), exposure(), exposure_absolute(), firevision::NaoCamera::exposure_auto(), exposure_auto(), exposure_auto_priority(), gain(), horiz_mirror(), hue(), lens_x_corr(), lens_y_corr(), red_balance(), saturation(), sharpness(), vert_mirror(), and white_balance_temperature().
|
virtual |
Get the current height of the image.
Implements firevision::CameraControlImage.
Definition at line 1590 of file v4l2.cpp.
References pixel_height().
Referenced by set_size().
|
virtual |
Return whether the camera image is horizontally mirrored.
NotImplementedException | Not implemented by this control |
Reimplemented from firevision::CameraControlImage.
Definition at line 1604 of file v4l2.cpp.
References get_one_control().
|
virtual |
Get current hue.
Implements firevision::CameraControlColor.
Definition at line 1531 of file v4l2.cpp.
References get_one_control().
Referenced by set_hue().
|
virtual |
Get current lens x correction.
NotImplementedException | Not implemented by this control |
Reimplemented from firevision::CameraControlImage.
Definition at line 1648 of file v4l2.cpp.
References get_one_control().
|
virtual |
Get current lens y correction.
NotImplementedException | Not implemented by this control |
Reimplemented from firevision::CameraControlImage.
Definition at line 1654 of file v4l2.cpp.
References get_one_control().
|
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 416 of file v4l2.cpp.
References _device_name, close(), and stop().
|
virtual |
Height of image in pixels.
Implements firevision::Camera.
Definition at line 1278 of file v4l2.cpp.
Referenced by height().
|
virtual |
Width of image in pixels.
Implements firevision::Camera.
Definition at line 1270 of file v4l2.cpp.
Referenced by width().
|
virtual |
Print out camera information.
Shall print out camera information and current setup information on stdout.
Implements firevision::Camera.
Definition at line 1674 of file v4l2.cpp.
References _device_name, and format().
|
virtual |
Camera is ready for taking pictures.
The camera has been opened and started correctly and may now provide images.
Implements firevision::Camera.
|
virtual |
Get current red balance.
Implements firevision::CameraControlColor.
Definition at line 1442 of file v4l2.cpp.
References get_one_control().
Referenced by set_red_balance().
|
virtual |
Get current saturation.
Implements firevision::CameraControlColor.
Definition at line 1518 of file v4l2.cpp.
References get_one_control().
Referenced by set_saturation().
|
virtual |
Enable/disable auto gain.
enabled | whether auto gain should be enabled |
Implements firevision::CameraControlColor.
Definition at line 1409 of file v4l2.cpp.
References set_one_control().
|
virtual |
Enable/disable auto white balance.
enabled | whether auto white balance should be enabled |
Implements firevision::CameraControlColor.
Definition at line 1422 of file v4l2.cpp.
References set_one_control().
|
virtual |
Set blue balance.
blue_balance | new blue balance |
Implements firevision::CameraControlColor.
Definition at line 1461 of file v4l2.cpp.
References blue_balance(), and set_one_control().
|
virtual |
Set new brightness.
brightness | new brightness |
Implements firevision::CameraControlColor.
Definition at line 1498 of file v4l2.cpp.
References brightness(), and set_one_control().
|
virtual |
Set new contrast.
contrast | new contrast |
Implements firevision::CameraControlColor.
Definition at line 1511 of file v4l2.cpp.
References contrast(), and set_one_control().
|
virtual |
Set new exposure.
exposure | new exposure |
Implements firevision::CameraControlColor.
Definition at line 1550 of file v4l2.cpp.
References exposure(), and set_one_control().
|
virtual |
set absolute exposure time (1/s)
exposure_absolute |
Definition at line 1375 of file v4l2.cpp.
References exposure_absolute(), and set_one_control().
|
virtual |
Enable/disable auto exposure.
enabled | whether auto exposure should be enabled |
Implements firevision::CameraControlColor.
Definition at line 1435 of file v4l2.cpp.
References exposure_auto(), and set_one_control().
|
virtual |
Set exposure_auto_priority V4L2 control.
enabled |
Definition at line 1327 of file v4l2.cpp.
References set_one_control().
|
virtual |
Set the image format the camera should use.
Check implementation documentation for details on the format.
format | the new image format |
NotImplementedException | Not implemented by this control |
Reimplemented from firevision::CameraControlImage.
Definition at line 1576 of file v4l2.cpp.
References format().
|
virtual |
Set the number of frames per second the camera tries to deliver.
fps | the new fps |
NotImplementedException | Not implemented by this control |
Reimplemented from firevision::CameraControlImage.
Definition at line 1641 of file v4l2.cpp.
References fps(), and set_fps().
Referenced by set_fps().
|
virtual |
Set new gain.
gain | new gain |
Implements firevision::CameraControlColor.
Definition at line 1563 of file v4l2.cpp.
References gain(), and set_one_control().
|
virtual |
Set whether the camera should mirror images horizontally.
enabled | if true, images should be mirrored horizontally |
NotImplementedException | Not implemented by this control |
Reimplemented from firevision::CameraControlImage.
Definition at line 1616 of file v4l2.cpp.
References set_one_control().
|
virtual |
Set new hue.
hue | new hue |
Implements firevision::CameraControlColor.
Definition at line 1537 of file v4l2.cpp.
References hue(), and set_one_control().
|
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().
n | image number to set |
Implements firevision::Camera.
|
virtual |
Set lens x correction.
x_corr | new lens x correction |
NotImplementedException | Not implemented by this control |
Reimplemented from firevision::CameraControlImage.
Definition at line 1660 of file v4l2.cpp.
References set_one_control().
|
virtual |
Set lens y correction.
y_corr | new lens y correction |
NotImplementedException | Not implemented by this control |
Reimplemented from firevision::CameraControlImage.
Definition at line 1667 of file v4l2.cpp.
References set_one_control().
|
protectedvirtual |
Set one Camera control value.
ctrl | name of the value |
id | ID of the value |
value | value to set |
Definition at line 864 of file v4l2.cpp.
References close().
Referenced by set_auto_gain(), set_auto_white_balance(), set_blue_balance(), set_brightness(), set_contrast(), set_exposure(), set_exposure_absolute(), firevision::NaoCamera::set_exposure_auto(), set_exposure_auto(), set_exposure_auto_priority(), set_gain(), set_horiz_mirror(), set_hue(), set_lens_x_corr(), set_lens_y_corr(), set_red_balance(), set_saturation(), set_sharpness(), set_vert_mirror(), and set_white_balance_temperature().
|
virtual |
Set red balance.
red_balance | new red balance |
Implements firevision::CameraControlColor.
Definition at line 1448 of file v4l2.cpp.
References red_balance(), and set_one_control().
|
virtual |
Set new saturation.
saturation | new saturation |
Implements firevision::CameraControlColor.
Definition at line 1524 of file v4l2.cpp.
References saturation(), and set_one_control().
|
virtual |
Set sharpness.
Lower = blurrier picture
sharpness |
Definition at line 1396 of file v4l2.cpp.
References set_one_control(), and sharpness().
|
virtual |
Set the image size the camera should use.
width | new width of the image |
height | new height of the image |
Exception | thrown for instance if size setting at run-time is not supported |
Implements firevision::CameraControlImage.
|
virtual |
|
virtual |
|
virtual |
Set whether the camera should mirror images vertically.
enabled | if true, images should be mirrored vertically |
NotImplementedException | Not implemented by this control |
Reimplemented from firevision::CameraControlImage.
Definition at line 1624 of file v4l2.cpp.
References set_one_control().
|
virtual |
Set white balance.
white_balance_temperature |
Definition at line 1350 of file v4l2.cpp.
References set_one_control(), and white_balance_temperature().
|
virtual |
Get sharpness value.
Definition at line 1386 of file v4l2.cpp.
References get_one_control().
Referenced by set_sharpness().
|
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.
|
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 1121 of file v4l2.cpp.
Referenced by close(), open(), start(), and ~V4L2Camera().
|
virtual |
|
virtual |
|
virtual |
Return whether the camera image is vertically mirrored.
NotImplementedException | Not implemented by this control |
Reimplemented from firevision::CameraControlImage.
Definition at line 1610 of file v4l2.cpp.
References get_one_control().
|
virtual |
Get absolute white balance setting.
Definition at line 1340 of file v4l2.cpp.
References get_one_control().
Referenced by set_white_balance_temperature().
|
virtual |
Get the current width of the image.
Implements firevision::CameraControlImage.
Definition at line 1584 of file v4l2.cpp.
References pixel_width().
Referenced by set_size().
|
protected |
Device name.
Definition at line 140 of file v4l2.h.
Referenced by firevision::NaoCamera::NaoCamera(), open(), print_info(), firevision::NaoCamera::set_source(), V4L2Camera(), and ~V4L2Camera().