DEV Community

Discussion on: How to capture picture using JavaScript | Webcam Js Tutorial

Collapse
 
polaroidkidd profile image
Daniel Einars

Webcam JS is in maintenance mode and the library linked to my the author of webcamjs is no longer maintained.

Recommending either of these libraries isn't good.

Collapse
 
stackfindover profile image
Stackfindover

Thanks, You're Right
Check more info about Webcam Js

Collapse
 
polaroidkidd profile image
Daniel Einars

getting the webcam these days is a lot easier than it used to be (with the exception of IE11, which doesn't have webcam features enabled without flash).

To get a webcam stream you can do


navigator.mediaDevices.getUserMedia({audio: false, video: true})
    .then((stream) => {
        // work with the stream, like assigning it to a video element and playing it. 
        // To Capture an image you can paint a reference to the video element to
        // the canvas and then  get the image from the canvas to work with.
        console.debug("stream: ", stream)
        })
    .catch((error) => {
        // some error occured
        console.error(error)
       })
Enter fullscreen mode Exit fullscreen mode