Recommend this page to a friend!
  Classes of Elger van Boxtel   JS Webcam   Download  
Role: Documentation
Content type: text/markdown
Description: Auxiliary data
Class: JS Webcam
Capture pictures or video with the webcam
Author: By
Last change: Add a Bitdeli badge to README
Date: 2 years ago
Size: 2,516 bytes


Class file image Download


Join the chat at Join the chat at

Make use of the webcam in the browser, using an optional fallback to use the camera of mobile devices or to upload pictures from disc.

Fork me on GitHub Example on:


| Method | Description | |-------------|-----------------------------------------------------------| | element | Returns the actual video HTMLElement | | fallback | Fallback mechanism to select files. Use this when you want to take pics from a mobile device or upload pictures from disc | | isStarted | Checks whether the webcam is started | | isSupported | Checks whether or not the API is supported by the browser | | start | Enables the webcam, will ask the user to share his webcam | | stop | Stops the Webcam object | | takePicture | Take a still image of the webcam, returns a Blob | | uriToBlob | Takes in a dataUri and transforms it into a Blob | | useFallback | Sets if a fallback mechanism should be in place to select files. Set this to true when you want to take pics from a mobile device or upload pictures from dics |


var webcam = new Webcam('#video');
if (webcam.isSupported()) {
	webcam.start({video: true, audio: false}, function(stream) {
      // success function, video is streaming...
    }, function(e) {
      alert('Oops, something went wrong');

    // now take an picture using the webcam
    var pic = webcam.takePicture();

    // and assign it to an image
    document.querySelector('#img').src = pic;
else {
	alert('API is not supported by your browser');

Reading material


Bitdeli Badge