upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
API for the Video Capture driver. More...
This UPM module captures a still frame from a Linux V4L device, such as a USB webcam, and and then allows you to save it as a JPEG image into a file.
The camera and driver in use must support streaming, mmap-able buffers and must provide data in YUYV format. This should encompass most video cameras out there. It has been tested with a few off the shelf cameras without any problems.
Public Member Functions | |
VCAP (std::string videoDev=VCAP_DEFAULT_VIDEODEV) | |
~VCAP () | |
bool | setResolution (int width, int height) |
bool | captureImage () |
bool | saveImage (std::string filename=VCAP_DEFAULT_OUTPUTFILE) |
int | getWidth () const |
int | getHeight () const |
void | setJPGQuality (unsigned int quality) |
int | getJPGQuality () const |
void | setDebug (bool enable) |
Protected Member Functions | |
bool | initVideoDevice () |
bool | checkCapabilities () |
bool | YUYV2JPEG (FILE *file) |
bool | allocBuffer () |
void | releaseBuffer () |
bool | doCaptureImage () |
VCAP | ( | std::string | videoDev = VCAP_DEFAULT_VIDEODEV | ) |
VCAP object constructor
videoDev | The path to the video device, default is /dev/video0. |
bool setResolution | ( | int | width, |
int | height | ||
) |
Set the desired resolution of the output image. Note, this is a hint to the underlying video driver. The video driver is free to lower the specified resolution if the hardware cannot support it. You can use getHeight() and getWidth() after calling this method to see what the video driver chose.
width | The desired width of the image. |
width | The desired height of the image. |
bool captureImage | ( | ) |
Capture an image from the camera.
bool saveImage | ( | std::string | filename = VCAP_DEFAULT_OUTPUTFILE | ) |
Save the captured image (created with captureImage()) to a file in JPEG format. The file will be overwritten if it already exists.
filename | The name of the file in which to store the image. |
|
inline |
Return the current width of the image. You can use this method to determine if the video driver downgraded it after a call to setResolution().
|
inline |
Return the current height of the image. You can use this method to determine if the video driver downgraded it after a call to setResolution().
void setJPGQuality | ( | unsigned int | quality | ) |
Set the JPEG quality.
quality | A number between 0-100, with higher numbers meaning higher quality. Numbers less than 0 will be clamped to 0, numbers higher than 100 will be clamped to 100. |
|
inline |
Get the current JPEG quality setting.
|
inline |
Enable or disable debugging output.
enable | true to enable debugging, false otherwise |