#Linux relies on fswebcam currently#ubuntusudo apt-get install fswebcam#arch#fswebcam requires a build from the AUR, it is not listed for installation on pacman/pamacsudo pamac build fswebcam
Mac OSX
#Mac OSX relies on imagesnap#Repo https://github.com/rharder/imagesnap#Avaliable through brewbrew install imagesnap
//Available in nodejsvar NodeWebcam = require( "node-webcam" );//Default optionsvar opts = { //Picture related width: 1280, height: 720, quality: 100, // Number of frames to capture // More the frames, longer it takes to capture // Use higher framerate for quality. Ex: 60 frames: 60, //Delay in seconds to take shot //if the platform supports miliseconds //use a float (0.1) //Currently only on windows delay: 0, //Save shots in memory saveShots: true, // [jpeg, png] support varies // Webcam.OutputTypes output: "jpeg", //Which camera to use //Use Webcam.list() for results //false for default device device: false, // [location, buffer, base64] // Webcam.CallbackReturnTypes callbackReturn: "location", //Logging verbose: false};//Creates webcam instancevar Webcam = NodeWebcam.create( opts );//Will automatically append location output typeWebcam.capture( "test_picture", function( err, data ) {} );//Also available for quick useNodeWebcam.capture( "test_picture", opts, function( err, data ) {});//Get list of camerasWebcam.list( function( list ) { //Use another device var anotherCam = NodeWebcam.create( { device: list[ 0 ] } );});//Return type with base 64 imagevar opts = { callbackReturn: "base64"};NodeWebcam.capture( "test_picture", opts, function( err, data ) { var image = "<img src='" + data + "'>";});
Shell Usage
#Config opts--width Picture width--height Picture height--delay Delay till shot--quality Quality of image 0-100--output Output type [png, jpg, bmp]--verbose Verbose debugging--help Usage help text--version node-webcam version--location Location to output webcam capture--list list available camera devices#Shorthand optionsw: [ "--width" ],h: [ "--height" ],d: [ "--delay" ],q: [ "--quality" ],out: [ "--output" ],h: [ "--help", true ],v: [ "--version", true ],l: [ "--location" ]#node-webcam will auto output the file type at the endnode-webcam --w 500 --h 500 --d 2 --l picture # ./bin/node-webcam.js
Webcam.capture( String location, Object options, Function callback( Error|Null, Buffer) )
First param of callback will be a possible error or null. Second will return the location of the image or null. The following functions will follow similarly. This function will auto append the output type if not specified in file name.
Webcam.getShot( Number shot, Function callback( Error|Null, Buffer) )
Webcam.getLastShot( Function callback )
Webcam.getBase64( Number|Buffer shot, Function callback( Error|Null, Buffer) )
Get base 64 of shot number or data already grabbed from FS.