devices/webcam -- camera capture

The devices/webcam module wraps navigator.mediaDevices.getUserMedia (with the devices/getUserMedia polyfill) in a small callback API: getStream(cb, constraints) asks for the camera, loadVideo(stream, video, cb) attaches the stream to a <video> and loadTimeout(ms) limits how long the video may take to start. Nothing is requested on load: pick the constraints, click Start camera (the browser asks for permission), Take snapshot draws the current frame on the canvas, Stop releases the camera (or cancels an unanswered request). Errors (no camera, permission denied, insecure page...) appear under the preview.

Preview

<video> -- fed by webcam.loadVideo(stream, video, cb)

<canvas> -- no snapshot yet

loading the module...
Controls
Log