|
camera_usb
|
#include <cam_config.h>
Classes | |
| struct | CamCtrl |
Public Member Functions | |
| CamConfig (std::string const &device) | |
| ~CamConfig () | |
| int | getFd () |
| void | readCapability () |
| void | listCapabilities () |
| std::string | getCapabilityDriver () |
| std::string | getCapabilityCard () |
| std::string | getCapabilityBusInfo () |
| std::string | getCapabilityVersion () |
| bool | hasCapability (uint32_t capability_field) |
| void | readControl () |
| void | readControl (struct v4l2_queryctrl &queryctrl_tmp) |
| int32_t | readControlValue (uint32_t const id) |
| void | writeControlValue (uint32_t const id, int32_t value, bool just_write=false) |
| std::vector< uint32_t > | getControlValidIDs () |
| std::vector< struct CamConfig::CamCtrl > | getControlList () |
| void | listControls () |
| bool | isControlIdValid (uint32_t const id) const |
| bool | isControlIdWritable (uint32_t const id) const |
| bool | getControlValue (uint32_t const id, int32_t *value) |
| bool | getControlType (uint32_t const id, uint32_t *type) |
| bool | getControlName (uint32_t const id, std::string *name) |
| bool | getControlMinimum (uint32_t const id, int32_t *minimum) |
| bool | getControlMaximum (uint32_t const id, int32_t *maximum) |
| bool | getControlStep (uint32_t const id, int32_t *step) |
| bool | getControlDefaultValue (uint32_t const id, int32_t *default_value) |
| bool | getControlFlag (uint32_t const id, uint32_t const flag, bool *set) |
| void | setControlValuesToDefault () |
| void | readImageFormat () |
| void | writeImagePixelFormat (uint32_t const width=0, uint32_t const height=0, uint32_t const pixelformat=0) |
| void | listImageFormat () |
| bool | getImageWidth (uint32_t *width) |
| bool | getImageHeight (uint32_t *height) |
| bool | getImagePixelformat (uint32_t *pixelformat) |
| bool | getImagePixelformatString (std::string *pixelformat_str) |
| bool | getImageField (uint32_t *field) |
| bool | getImageBytesperline (uint32_t *bytesperline) |
| bool | getImageSizeimage (uint32_t *sizeimage) |
| bool | getImageColorspace (uint32_t *colorspace) |
| uint32_t | toV4L2ImageFormat (base::samples::frame::frame_mode_t mode) |
| void | readStreamparm () |
| void | writeStreamparm (uint32_t const numerator, uint32_t const denominator) |
| void | listStreamparm () |
| bool | readFPS (float *fps) |
| void | writeFPS (uint32_t const fps) |
| bool | getFPS (float *fps) |
| bool | hasCapabilityStreamparm (uint32_t capability_field) |
| bool | hasCapturemodeStreamparm (uint32_t capturemode) |
| void | initRequesting () |
| bool | isImageAvailable (int32_t timeout_ms) |
| bool | getBuffer (std::vector< uint8_t > &buffer, bool blocking_read, int32_t timeout_ms) |
| void | cleanupRequesting () |
Using v4l2 to read and set the parameters of the specified camera and to read camera images as well. Important: For newly-connected cameras the device driver may return a wrong image size! Prevent that by calling writeImagePixelFormat() without any parameters during initialization.
| camera::CamConfig::CamConfig | ( | std::string const & | device | ) |
Opens the device and reads all camera informations. Throws std::runtime_error if the device could not be opened or an io-error occurred. TODO Remove read...() from constructor, so its up to the user to read the required informations?
| camera::CamConfig::~CamConfig | ( | ) |
| void camera::CamConfig::cleanupRequesting | ( | ) |
| bool camera::CamConfig::getBuffer | ( | std::vector< uint8_t > & | buffer, |
| bool | blocking_read, | ||
| int32_t | timeout_ms | ||
| ) |
Used http://www.jayrambhia.com/blog/capture-v4l2
| blocking_read | Not used, function always waits timeout_ms milliseconds. |
| std::string camera::CamConfig::getCapabilityBusInfo | ( | ) |
| std::string camera::CamConfig::getCapabilityCard | ( | ) |
| std::string camera::CamConfig::getCapabilityDriver | ( | ) |
| std::string camera::CamConfig::getCapabilityVersion | ( | ) |
| bool camera::CamConfig::getControlDefaultValue | ( | uint32_t const | id, |
| int32_t * | default_value | ||
| ) |
| bool camera::CamConfig::getControlFlag | ( | uint32_t const | id, |
| uint32_t const | flag, | ||
| bool * | set | ||
| ) |
Checks whether the passed control flag is set within the control. Valid flags are: V4L2_CTRL_FLAG_DISABLED, V4L2_CTRL_FLAG_GRABBED, V4L2_CTRL_FLAG_READ_ONLY, V4L2_CTRL_FLAG_UPDATE, V4L2_CTRL_FLAG_INACTIVE, V4L2_CTRL_FLAG_SLIDER and V4L2_CTRL_FLAG_WRITE_ONLY.
| std::vector< struct CamConfig::CamCtrl > camera::CamConfig::getControlList | ( | ) |
Returns a copy of all available controls.
| bool camera::CamConfig::getControlMaximum | ( | uint32_t const | id, |
| int32_t * | maximum | ||
| ) |
| bool camera::CamConfig::getControlMinimum | ( | uint32_t const | id, |
| int32_t * | minimum | ||
| ) |
| bool camera::CamConfig::getControlName | ( | uint32_t const | id, |
| std::string * | name | ||
| ) |
| bool camera::CamConfig::getControlStep | ( | uint32_t const | id, |
| int32_t * | step | ||
| ) |
| bool camera::CamConfig::getControlType | ( | uint32_t const | id, |
| uint32_t * | type | ||
| ) |
| std::vector< uint32_t > camera::CamConfig::getControlValidIDs | ( | ) |
Returns list of valid control IDs.
| bool camera::CamConfig::getControlValue | ( | uint32_t const | id, |
| int32_t * | value | ||
| ) |
Gets the last set control value, use 'readControl()' if you want to get the current value set on the camera.
|
inline |
| bool camera::CamConfig::getFPS | ( | float * | fps | ) |
Returns denominator / numerator. If you want to read the current value from the camera use 'readFPS()', but be careful that the device is not busy.
| fps | Sets fps to 0 if not set. |
| bool camera::CamConfig::getImageBytesperline | ( | uint32_t * | bytesperline | ) |
For padding, zero if unused.
| bool camera::CamConfig::getImageColorspace | ( | uint32_t * | colorspace | ) |
| bool camera::CamConfig::getImageField | ( | uint32_t * | field | ) |
Whats this?
| bool camera::CamConfig::getImageHeight | ( | uint32_t * | height | ) |
| bool camera::CamConfig::getImagePixelformat | ( | uint32_t * | pixelformat | ) |
| bool camera::CamConfig::getImagePixelformatString | ( | std::string * | pixelformat_str | ) |
| bool camera::CamConfig::getImageSizeimage | ( | uint32_t * | sizeimage | ) |
| bool camera::CamConfig::getImageWidth | ( | uint32_t * | width | ) |
| bool camera::CamConfig::hasCapability | ( | uint32_t | capability_field | ) |
| field | E.g. V4L2_CAP_VIDEO_CAPTURE or V4L2_CAP_VIDEO_OUTPUT. See include/linux/videodev2.h for details. |
| bool camera::CamConfig::hasCapabilityStreamparm | ( | uint32_t | capability_field | ) |
Only supported flag: V4L2_CAP_TIMEPERFRAME (is it allowd to change the fps).
| bool camera::CamConfig::hasCapturemodeStreamparm | ( | uint32_t | capturemode | ) |
Only supported flag: V4L2_MODE_HIGHQUALITY. Used to get single images in maximal quality.
| void camera::CamConfig::initRequesting | ( | ) |
| bool camera::CamConfig::isControlIdValid | ( | uint32_t const | id | ) | const |
Returns whether this v4l control ID is available on this device
| bool camera::CamConfig::isControlIdWritable | ( | uint32_t const | id | ) | const |
Returns whether this v4l control ID is available on this device, and whether it can be written to
| bool camera::CamConfig::isImageAvailable | ( | int32_t | timeout_ms | ) |
Uses select() to check if an image is available.
| void camera::CamConfig::listCapabilities | ( | ) |
| void camera::CamConfig::listControls | ( | ) |
| void camera::CamConfig::listImageFormat | ( | ) |
| void camera::CamConfig::listStreamparm | ( | ) |
| void camera::CamConfig::readCapability | ( | ) |
| void camera::CamConfig::readControl | ( | ) |
Generates a list of valid controls requesting all base and private base controls ids. The private base control ids of the e-CAM32 are requested as well (see omap_v4l2.h of the e-CAM32 driver source). readControl(struct v4l2_queryctrl& queryctrl_tmp) doing the main job here.
| void camera::CamConfig::readControl | ( | struct v4l2_queryctrl & | queryctrl_tmp | ) |
Stores the supported control ids and their current values.
| int32_t camera::CamConfig::readControlValue | ( | uint32_t const | id | ) |
Requests current value from the camera directly.
| id | control id like V4L2_CID_BRIGHTNESS or V4L2_CID_CONTRAST, see include/linux/videodev2.h for details. Throws runtime_error if the value could not be requested or the passed id is unknown. |
| bool camera::CamConfig::readFPS | ( | float * | fps | ) |
| void camera::CamConfig::readImageFormat | ( | ) |
| void camera::CamConfig::readStreamparm | ( | ) |
| void camera::CamConfig::setControlValuesToDefault | ( | ) |
Sets all control (except V4L2_CID_WHITE_BALANCE_TEMPERATURE) values to their default value.
| uint32_t camera::CamConfig::toV4L2ImageFormat | ( | base::samples::frame::frame_mode_t | mode | ) |
Tries to map a rock to a v4l2 mode. Problem is that rock only supports a few image formats and e.g. no YUYV which is a base raw format for most of the cameras. So if RGB is requested but not available YUV will be used and converted to RGB.
| void camera::CamConfig::writeControlValue | ( | uint32_t const | id, |
| int32_t | value, | ||
| bool | just_write = false |
||
| ) |
Changes the control value on the camera and in the internally stored controls. The passed id and value have to be valid, otherwise a runtime_error is thrown. V4L2_CID_WHITE_BALANCE_TEMPERATURE can not be set (at least on the test camera Microsoft LifeCam Cinema(TM), therefore this parameter is ignored at the moment.
| just_write | If set to true, the passed control value will just be written (without any checks and without storing the new value in 'mCamCtrls'). This is used to test whether the control is writeable. |
| void camera::CamConfig::writeFPS | ( | uint32_t const | fps | ) |
Tries to set the passed fps, just use writeStreamparm(1,fps). Throws std::runtime_error if an io-error occurred.
| void camera::CamConfig::writeImagePixelFormat | ( | uint32_t const | width = 0, |
| uint32_t const | height = 0, |
||
| uint32_t const | pixelformat = 0 |
||
| ) |
Tries to write the requested image size and the pixelformat. Driver will set the most suitable and stores it in mFormat. If you do not want to change a parameter, just pass 0. Requires type V4L2_BUF_TYPE_VIDEO_CAPTURE. E.g. V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_MJPEG. Pass 0 to use the current pixel format which is set on the camera. See include/linux/videodev2.h for details.
| void camera::CamConfig::writeStreamparm | ( | uint32_t const | numerator, |
| uint32_t const | denominator | ||
| ) |
Numerator/Denominator, e.g. 1/30. Be aware: Changes to the FPS get lost after closing the device.
1.8.6