Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Create readable streams from connected webcams

branch: master
Octocat-spinner-32 lib snapshot error August 19, 2013
Octocat-spinner-32 test snapshot error August 19, 2013
Octocat-spinner-32 .gitignore native module gitignore April 24, 2012
Octocat-spinner-32 .npmignore native module npmignore April 24, 2012
Octocat-spinner-32 .travis.yml fix opencv package name October 25, 2012
Octocat-spinner-32 LICENSE fix for 2012 January 22, 2012
Octocat-spinner-32 README.md Update README.md March 30, 2014
Octocat-spinner-32 index.js dep fixes - 0.0.5 March 30, 2014
Octocat-spinner-32 package.json dep fixes - 0.0.5 March 30, 2014
README.md

status

Information

Package camera
Description Create readable streams from connected webcams
Node Version >= 0.4

Dependencies

This library requires that you have OpenCV installed - go to the OpenCV site for instructions.

Usage

createStream([camera idx])

The object returned from createStream is a full readable Stream - you can pause, resume, destroy, pipe, etc.

createStream optionally takes a camera number and defaults to 0 for the main camera

Each data event is a full image buffer from the camera - the framerate is variable on your CPU (should be an option in the future). Image buffers are PNGs. To convert the buffer to a base64 data uri (for the browser) just do "data:image/png;base64," + buffer.toString('base64')

camera = require 'camera'

webcam = camera.createStream()

webcam.on 'data', (buffer) ->
  # do something with image buffer

snapshot(callback)

Returns an error and one image buffer to the given callback.

record(milliseconds, cb)

Returns an array of video frames for the time-span specified in milliseconds

Examples

Take a picture

fs = require 'fs'
camera = require 'camera'

webcam = camera.createStream()

webcam.on 'error', (err) ->
  console.log 'error reading data', err

webcam.on 'data', (buffer) ->
  fs.writeFileSync 'cam.png', buffer
  webcam.destroy()

webcam.snapshot (err, buffer) ->

webcam.record 1000, (buffers) ->

LICENSE

(MIT License)

Copyright (c) 2012 Fractal contact@wearefractal.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge

Something went wrong with that request. Please try again.