27
index.js
@@ -1,3 +0,3 @@ | ||
const from = require('from2') | ||
const cv = require('opencv4nodejs') | ||
const { Readable } = require('stream') | ||
const cv = require('@u4/opencv4nodejs') | ||
@@ -8,4 +8,13 @@ module.exports = { | ||
const s = from((count, cb) => { | ||
s.snapshot(cb) | ||
const s = new Readable({ | ||
objectMode: true, | ||
read() { | ||
s.snapshot((err, data) => { | ||
if (err) { | ||
this.destroy(err) | ||
return | ||
} | ||
this.push(data) | ||
}) | ||
} | ||
}) | ||
@@ -20,11 +29,11 @@ | ||
s.record = (ms, cb) => { | ||
const vid = [] | ||
const push = (buf) => vid.push(buf) | ||
s.record = (duration, cb) => { | ||
const frames = [] | ||
const push = (buf) => frames.push(buf) | ||
const clear = () => { | ||
s.removeListener('data', push) | ||
cb(vid) | ||
cb(frames) | ||
} | ||
setTimeout(clear, ms) | ||
setTimeout(clear, duration) | ||
s.on('data', push) | ||
@@ -31,0 +40,0 @@ } |
{ | ||
"name": "camera", | ||
"description": "Just a dead simple package to create readable streams from connected webcams", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"homepage": "http://github.com/contra/camera", | ||
@@ -10,5 +10,7 @@ "repository": "git://github.com/contra/camera.git", | ||
"dependencies": { | ||
"from2": "^2.3.0", | ||
"opencv4nodejs": "^5.6.0" | ||
"@u4/opencv4nodejs": "^7.1.2" | ||
}, | ||
"opencv4nodejs": { | ||
"disableAutoBuild": "1" | ||
}, | ||
"devDependencies": { | ||
@@ -15,0 +17,0 @@ "mocha": "*", |
@@ -23,3 +23,6 @@  | ||
You may need to `export OPENCV4NODEJS_DISABLE_AUTOBUILD=1` before running `npm install`. | ||
## Specific for macOS | ||
Install OpenCV using brew | ||
@@ -26,0 +29,0 @@ ```bash |
Unstable ownership
Supply chain riskA new collaborator has begun publishing package versions. Package stability and security risk may be elevated.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
6655
5.28%1
-50%113
8.65%90
3.45%1
Infinity%