Module: @accessors-modules/cameras

Module to access camera hardware on the host.

This implementation uses the opencv npm module by Peter Braden, see

  • $$Id$$
  • Christopher Brooks, based on the Cape Code cameras module by Edward A. Lee


(static) Camera(name)

Construct an instance of an Camera object type. To capture an image from the default camera, you can do this:

    var cameras = require("cameras");
    var camera = new cameras.Camera();;
    var image = camera.snapshot();
The image will be a binary object. This object can be sent to an output port displayed or otherwise further processed. To capture every image from the camera, you can do this:
    var cameras = require("cameras");
    var camera = new cameras.Camera();
    camera.on('image', function(image) { ... handle the image ... });;
An instance of this object type implements the following functions:
  • close(): Close the camera.
  • getViewSize(): Return the current view size for this camera as a JSON string, as in {"width":176, "height":144}.
  • on(event, handler): Specify an event handler for the camera.
  • open(): Open the camera.
  • setViewSize(size): Set the current view size for this camera. The argument can either be a JSON string or an object with a width and height field, as in for example {"width":176, "height":144}.
  • snapshot(): Return the last image recorded by the camera.
  • viewSizes(): Return an array of view sizes supported by this camera, each given as a JSON string of the form '{"width":176, "height":144}', for example.
An instance of this object emits the following events:
  • "opened": The camera has been opened.
  • "image": A new image has been obtained.
  • "closed": The camera has been closed.

Name Type Description

The camera name, or null to use the default camera.


(static) cameras()

Return an array of camera names for cameras currently available on the current host. This array includes a special name "default camera", which represents the system default camera, if there is one.


An array of names, or null if there are no cameras.

(static) defaultCamera()

Return the name of the default camera on the current host, or null if there is none.


A camera name.