UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

VCAP Class

Module: vcap
  • 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.

Methods

VCAP

(
  • videoDev
)
Number

VCAP object constructor

Parameters:

  • videoDev String

    The path to the video device, default is /dev/video0.

Returns:

Number:

setResolution

(
  • width
  • height
)
Boolean

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 Number

    The desired height of the image.

  • height Number

    undefined

Returns:

Boolean:

true if the operation succeeded, false otherwise.

captureImage

() Boolean

Capture an image from the camera.

Returns:

Boolean:

true if the operation succeeded, false otherwise.

saveImage

(
  • filename
)
Boolean

Save the captured image (created with captureImage() ) to a file in JPEG format. The file will be overwritten if it already exists.

Parameters:

  • filename String

    The name of the file in which to store the image.

Returns:

Boolean:

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:

Number:

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:

Number:

true Current height of capture.

setJPGQuality

(
  • quality
)

Set the JPEG quality.

Parameters:

  • quality Number

    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.

getJPGQuality

() Number

Get the current JPEG quality setting.

Returns:

Number:

the current JPEG quality setting.

setDebug

(
  • enable
)

Enable or disable debugging output.

Parameters:

  • enable Boolean

    true to enable debugging, false otherwise