Skip to content

Webcam

USB webcam/video capture using OpenCV. Streams base64-encoded JPEG frames at a configurable framerate.

Safety gate

This driver ships with requiresSafetyGates: false — webcam writes and actions bypass the safety gate entirely, and no audit rows are written. See Per-driver opt-out.

Properties

PropertyTypeAccessUnitDescription
widthintR/WpxFrame width
heightintR/WpxFrame height
fpsintR/WTarget framerate
qualityintR/WJPEG quality (1–100)
brightnessintR/WBrightness (0–100)
contrastintR/WContrast (0–100)
flipHboolR/WHorizontal flip (mirror)
flipVboolR/WVertical flip
deviceintRCamera device index
streamingboolRWhether capture is active
resolutionstringRCurrent resolution string (e.g., "640x480")

Actions

ActionArgsDescription
startStart video capture and streaming
stopStop video capture and streaming
snapshotCapture a single frame, return as base64 JPEG

Streams

StreamDescription
videoBase64 JPEG frames at the configured FPS

Config Options

OptionTypeDefaultDescription
deviceint0Camera device index (0 = first camera)
widthint640Capture width in pixels
heightint480Capture height in pixels
fpsint15Target framerate
qualityint75JPEG quality (1–100)
brightnessint50Brightness (0–100)
contrastint50Contrast (0–100)

Video Recording

The Webcam driver supports video recording to workspace/data/recordings/. See also ONVIF which shares the same recording interface.

Recording Actions:

ActionArgsReturnsDescription
recordseconds, filename?filenameRecord for N seconds (blocks until done)
recordStartfilename?filenameStart recording (manual stop)
recordStopfilenameStop recording, finalize file

Recording Property:

PropertyTypeAccessDescription
recordingboolRWhether recording is active
  • Output format: MP4 (MP4V codec), falls back to AVI (MJPEG) if codec unavailable
  • Auto-starts the camera stream if not already streaming
  • Filename is auto-generated (Webcam_{timestamp}.mp4) if not specified

Example Connector

javascript
// workspace/connectors/webcam.js
export default {
  driver: "Webcam",
  config: {
    device: 0,
    width: 1280,
    height: 720,
    fps: 15,
    quality: 80,
  },
  poll: ["streaming", "resolution"],
};

Dashboard Integration

Display the webcam feed with a canvas widget:

json
{
  "type": "canvas",
  "config": {
    "label": "Webcam",
    "mode": "image",
    "stream": "webcam:video"
  }
}

Take a snapshot from a script:

javascript
const cam = connector("webcam");
cam.start();
const frame = cam.snapshot;  // base64 JPEG string
log.info(`Captured frame: ${frame.length} chars`);

Note: Requires OpenCV native libraries, which ship bundled with the Windows build.

Muxit — Hardware Orchestration Platform