GithubHelp home page GithubHelp logo

camera's Introduction

status

Information

Packagecamera
Description Just a dead simple package to create readable streams from connected webcams
Node Version >=12

Install

You'll need OpenCV 4 or newer installed before installing.

Specific for macOS

Install OpenCV using brew

brew update
brew install opencv@4
brew link --force opencv@4

Usage

createStream([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 primary camera.
  • Each data event is a full image buffer from the camera.
  • 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')}
const camera = require('camera')

const webcam = camera.createStream()

webcam.on('data', (buffer) => {
  // do something with image buffer
})

snapshot(cb)

Returns an error and one image buffer to the given callback. Useful if you just want to grab a simple photo.

record(milliseconds, cb)

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

Examples

Take a picture

const fs = require('fs')
const camera = require('camera')

const 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) => {
  
})

camera's People

Contributors

bitdeli-chef avatar funkytek avatar ralphtheninja avatar yocontra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

camera's Issues

"npm install camera" error

npm ERR! Failed at the [email protected] preinstall script.
npm ERR! This is most likely a problem with the opencv package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp clean rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls opencv
npm ERR! There is likely additional logging output above.


Hey I'm trying to install this package.. I'm using..

osX Lion 10.7.5
OpenCV 2.4.2
node 10.2

I installed opencv using macports.. not sure its that my problem or the fact that I have little to no idea on what I'm doing :L

error when requiring camera

Seems to be related to coffee-script not compiling properly. Anyone else seen this before? If I manually compile main.coffee to main.js then it works perfectly.

module.js:340
    throw err;
          ^
Error: Cannot find module './lib/main'
  at Function.Module._resolveFilename (module.js:338:15)
  at Function.Module._load (module.js:280:25)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/home/lms/src/opencv-test/node_modules/camera/index.js:2:18)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Module.require (module.js:364:17)
  at require (module.js:380:17)
  at Object.<anonymous> (/home/lms/src/opencv-test/index.js:22:14)
  at Module._compile (module.js:456:26)
  at Object.Module._extensions..js (module.js:474:10)
  at Module.load (module.js:356:32)
  at Function.Module._load (module.js:312:12)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:901:3

VIDIOC_QUERYMENU: Invalid argument

Hi,

I try to make a little program with the example to take screenshot with my webcam.
I have installed OpenCV and I write this piece of code :

var camera = require('camera');
var fs = require('fs');

var webcam = camera.createStream();

webcam.on('data', function(buffer) {
    fs.writeFileSync('cam.jpg', buffer);
    webcam.destroy();
});

when I execute this code, I have an error :

VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
/home/pi/babycamble/node_modules/camera/lib/main.coffee:1038: Uncaught TypeError: Cannot call method 'toBuffer' of null

and no image was save... a solution ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.