VCAP Class
- ID: vcap
- Name: Video Frame Capture and Image Save Utility
- Category: video
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.
Item Index
Methods
VCAP
-
videoDev
VCAP object constructor
Parameters:
-
videoDev
StringThe path to the video device, default is /dev/video0.
Returns:
setResolution
-
width
-
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.
Parameters:
-
width
NumberThe desired height of the image.
-
height
Numberundefined
Returns:
true if the operation succeeded, false otherwise.
captureImage
()
Boolean
Capture an image from the camera.
Returns:
true if the operation succeeded, false otherwise.
saveImage
-
filename
Save the captured image (created with captureImage() ) to a file in JPEG format. The file will be overwritten if it already exists.
Parameters:
-
filename
StringThe name of the file in which to store the image.
Returns:
true if the operation succeeded, false otherwise.
getWidth
()
Number
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() .
Returns:
true Current width of capture.
getHeight
()
Number
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() .
Returns:
true Current height of capture.
setJPGQuality
-
quality
Set the JPEG quality.
Parameters:
-
quality
NumberA 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.
getJPGQuality
()
Number
Get the current JPEG quality setting.
Returns:
the current JPEG quality setting.
setDebug
-
enable
Enable or disable debugging output.
Parameters:
-
enable
Booleantrue to enable debugging, false otherwise