npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-webcam

v0.8.2

Published

Cross platform webcam capture

Downloads

1,901

Readme

node-webcam

Cross platform webcam usage

Install

Linux

#Linux relies on fswebcam currently
#ubuntu

sudo apt-get install fswebcam

#arch
#fswebcam requires a build from the AUR, it is not listed for installation on pacman/pamac

sudo pamac build fswebcam

Mac OSX

#Mac OSX relies on imagesnap
#Repo https://github.com/rharder/imagesnap
#Avaliable through brew

brew install imagesnap

Windows

Standalone exe included. See src/bindings/CommandCam

Usage

API Usage

//Available in nodejs

var NodeWebcam = require( "node-webcam" );


//Default options

var 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 instance

var Webcam = NodeWebcam.create( opts );


//Will automatically append location output type

Webcam.capture( "test_picture", function( err, data ) {} );


//Also available for quick use

NodeWebcam.capture( "test_picture", opts, function( err, data ) {

});


//Get list of cameras

Webcam.list( function( list ) {

    //Use another device

    var anotherCam = NodeWebcam.create( { device: list[ 0 ] } );

});

//Return type with base 64 image

var 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 options

w: [ "--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 end

node-webcam --w 500 --h 500 --d 2 --l picture # ./bin/node-webcam.js

Generated Documentation

# install yuidoc and run
./bin/generate_doc.sh

Classes

NodeWebcam

Main require used. Also has helper functions just for you.

NodeWebcam.create( Object options )

Main factory creation of a webcam for use. Uses NodeWebcam.Factory to create.

//Default options defined in API usage

var NodeWebcam = require( "node-webcam" );

var Webcam = NodeWebcam.create({});

NodeWebcam.capture( String location, Object options, Function callback )

Quick helper for taking pictures via one function. Will return Webcam instance via NodeWebcam.create.

NodeWebcam.capture( "my_picture", {}, function( err, data ) {

    if ( !err ) console.log( "Image created!" );

});

Webcam

Base webcam class in which all other cameras inherit from

Webcam.constructor( Object options )

//Default options and basic usage

var opts = {

    width: 1280,

    height: 720,

    delay: 0,

    quality: 100,

    // [jpeg, png] support varies
    // Webcam.OutputTypes

    output: "jpeg",

    device: false,


    // [buffer, base64]
    // Webcam.CallbackReturnTypes

    callbackReturn: "location",

    verbose: false

}

var cam = new Webcam( opts );

Webcam.clone()

Webcam.clear()

Reset data and memory of past shots

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.

FSWebcam

Uses the fswebcam program. Available in linux (apt-get install fswebcam). Extra program addons provided in options.

var NodeWebcam = require( "node-webcam" );

var FSWebcam = NodeWebcam.FSWebcam; //require( "node-webcam/webcams/FSWebcam" );

var opts = {};

var cam = new FSWebcam( opts );

What's next?

  • Video capture functionality
  • Battle testing
  • What do you want to see? Leave an issue on the github page!