|
camera_usb
|
#include <cam_usb.h>
Public Member Functions | |
| CamUsb (std::string const &device) | |
| ~CamUsb () | |
| void | fastInit (int width, int height) |
| virtual int | listCameras (std::vector< CamInfo > &cam_infos) const |
| virtual bool | open (const CamInfo &cam, const AccessMode mode=Master) |
| bool | isOpen () const |
| virtual const CamInfo * | getCameraInfo () const |
| virtual bool | close () |
| virtual bool | grab (const GrabMode mode=SingleFrame, const int buffer_len=1) |
| virtual bool | retrieveFrame (base::samples::frame::Frame &frame, const int timeout=1000) |
| bool | storeFrame (base::samples::frame::Frame &frame, std::string const &file_name) |
| virtual bool | isFrameAvailable () |
| virtual int | skipFrames () |
| virtual bool | setIpSettings (const CamInfo &cam, const IPSettings &ip_settings) const |
| virtual bool | setAttrib (const int_attrib::CamAttrib attrib, const int value) |
| virtual bool | setAttrib (const double_attrib::CamAttrib attrib, const double value) |
| virtual bool | setAttrib (const str_attrib::CamAttrib attrib, const std::string value) |
| virtual bool | setAttrib (const enum_attrib::CamAttrib attrib) |
| virtual bool | isAttribAvail (const int_attrib::CamAttrib attrib) |
| virtual bool | isAttribAvail (const double_attrib::CamAttrib attrib) |
| virtual bool | isAttribAvail (const str_attrib::CamAttrib attrib) |
| virtual bool | isAttribAvail (const enum_attrib::CamAttrib attrib) |
| virtual int | getAttrib (const int_attrib::CamAttrib attrib) |
| virtual double | getAttrib (const double_attrib::CamAttrib attrib) |
| virtual std::string | getAttrib (const str_attrib::CamAttrib attrib) |
| virtual bool | isAttribSet (const enum_attrib::CamAttrib attrib) |
| bool | isV4L2AttribAvail (const int control_id, std::string name="") |
| int | getV4L2Attrib (const int control_id) |
| bool | setV4L2Attrib (const int control_id, const int value) |
| bool | setFrameSettings (const base::samples::frame::frame_size_t size, const base::samples::frame::frame_mode_t mode, const uint8_t color_depth, const bool resize_frames=true) |
| virtual bool | getFrameSettings (base::samples::frame::frame_size_t &size, base::samples::frame::frame_mode_t &mode, uint8_t &color_depth) |
| virtual bool | triggerFrame () |
| virtual bool | setToDefault () |
| bool | printCameraInformations () |
| virtual bool | setCallbackFcn (void(*pcallback_function)(const void *p), void *p) |
| virtual void | synchronizeWithSystemTime (uint32_t time_interval) |
| virtual void | saveConfiguration (uint8_t index) |
| virtual void | loadConfiguration (uint8_t index) |
| virtual void | getRange (const double_attrib::CamAttrib attrib, double &dmin, double &dmax) |
| virtual void | getRange (const int_attrib::CamAttrib attrib, int &imin, int &imax) |
| virtual int | getFileDescriptor () const |
| enum CAM_USB_MODE | getCamMode () |
| double | calculateFPS () |
Static Public Attributes | |
| static const uint32_t | CAM_ID = 0 |
Allows configuration and image-requesting of cameras supported by Video4Linux.
You can use 'fastInit(width, height)' for the steps 2, 3 and 4.
| camera::CamUsb::CamUsb | ( | std::string const & | device | ) |
| camera::CamUsb::~CamUsb | ( | ) |
|
inline |
|
virtual |
Close camera, sets camera mode to CAM_USB_NONE (configuration or image requesting is not possible anymore).
| void camera::CamUsb::fastInit | ( | int | width, |
| int | height | ||
| ) |
Fast configuration of the camera (step 2 to 4). Opens the camera and sets the frame size. After this configuration, additional attributes can be set, the camera can be started by using grab() and the images can be retrieved with retrieveFrame(). If the camera does not support the passed width and height, an appropriate image size will be set.
|
virtual |
Returns the control value or throws a std::runtime_error.
|
virtual |
Returns the fps of the camera or throws a std::runtime_error.
|
inlinevirtual |
|
virtual |
|
inline |
|
virtual |
The pipeline must be running.
|
virtual |
|
inlinevirtual |
|
virtual |
| int camera::CamUsb::getV4L2Attrib | ( | const int | control_id | ) |
Allows to request the last read control value (the value will not be re-read from the camera).
| std::runtime_error |
| control_id | Control id to request. |
|
virtual |
To start the pipeline, just set 'mode' to sth. other than Stop (SingleFrame, MultiFrame or Continuously). Images are always grapped continuously. Pass Stop to stop grabbing and reenter the configuration mode. Could throw std::runtime_error if the passed mode is unknown or the mode should changed during the pipeline is running.
|
virtual |
Returns true if the attribute can be used with the camera. Excludes int_attrib::ExposureValue at the moment, because problems occurs using the Microsoft LiveCam.
|
virtual |
Returns true if the fps could be set on the camera.
|
inlinevirtual |
|
virtual |
Returns true if the attribute can be used with the camera.
|
virtual |
Returns true if the enumeration attribute is set or throws a std::runtime_error.
|
virtual |
Same as grab(), returns true if a new image is available.
| bool camera::CamUsb::isOpen | ( | ) | const |
| bool camera::CamUsb::isV4L2AttribAvail | ( | const int | control_id, |
| std::string | name = "" |
||
| ) |
Can be used to check the availability of v4l2 control IDs directly.
| control_id | id of the control to check. |
| name | For different cameras the same private base control id addresses different controls. If the name parameter is used, the name of the control is checked as well. |
|
virtual |
Adds the single cam_info structure to the passed vector. The cam_info.display_name will be added later, as soon as the connection to the camera has been opened.
|
inlinevirtual |
|
virtual |
Stores the passed CamInfo structure and opens camera for configuration via v4l2.
| bool camera::CamUsb::printCameraInformations | ( | ) |
List all camera informations. BASE_LOG_LEVEL has to be set to INFO.
|
virtual |
Reads a JPEG and initializes the passed frame (blocking read).
|
inlinevirtual |
|
virtual |
Write the control value to the camera or throws a std::runtime_error.
|
virtual |
Sets the FPS or throws a std::runtime_error. This method just sets the member variable mFps. You have to close and reopen the camera to take the new fps will take into account.
|
inlinevirtual |
|
virtual |
Switches the enumeration attribute or throws a std::runtime_error.
|
inlinevirtual |
| bool camera::CamUsb::setFrameSettings | ( | const base::samples::frame::frame_size_t | size, |
| const base::samples::frame::frame_mode_t | mode, | ||
| const uint8_t | color_depth, | ||
| const bool | resize_frames = true |
||
| ) |
If necessary 'size' will be changed to a valid one. 'mode' should be set to base::samples::frame::MODE_JPEG and 'color_depth' to the bytes per pixel.
|
virtual |
|
virtual |
Sets all control values on the camera back to default values. The image size and the fps are not affected. The connection to the camera has to be closed.
| bool camera::CamUsb::setV4L2Attrib | ( | const int | control_id, |
| const int | value | ||
| ) |
Sets the v4l2 control id directly.
| control_id | Control id to set the value for. |
| value | Value to set. |
| std::runtime_error | if the configuration mode is not active, the passed id is unknown or writeControlValue() throws an exception. |
|
virtual |
Skips the current image if available.
| bool camera::CamUsb::storeFrame | ( | base::samples::frame::Frame & | frame, |
| std::string const & | file_name | ||
| ) |
Stores the last retrieved frame to 'file_name'.
|
inlinevirtual |
|
virtual |
Frames are requested continuously.
|
static |
1.8.6