pyupm_vcap module

class pyupm_vcap.VCAP(*args)[source]

Bases: object

API for the Video Capture driver.

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.

C++ includes: vcap.hpp

captureImage()[source]

bool captureImage()

Capture an image from the camera.

true if the operation succeeded, false otherwise.

getHeight()[source]

int getHeight() const

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().

true Current height of capture.

getJPGQuality()[source]

int getJPGQuality() const

Get the current JPEG quality setting.

the current JPEG quality setting.

getWidth()[source]

int getWidth() const

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().

true Current width of capture.

saveImage(*args)[source]

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.

true if the operation succeeded, false otherwise.

setDebug(enable)[source]

void setDebug(bool enable)

Enable or disable debugging output.

enable: true to enable debugging, false otherwise

setJPGQuality(quality)[source]

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.

setResolution(width, height)[source]

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.

true if the operation succeeded, false otherwise.