Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
A node.js motion detection library written in JavaScript.
npm install motion
var Motion = require('motion').Motion;
var motion = new Motion();
var hasMotion = motion.detect(image1, image2);
Array
of Number
Array
of Number
Detect is called with one or two flat arrays of RGBA values. If called with one parameter, detect will use the last image1
as image2
.
var Motion = require('motion').Motion;
var motion = new Motion();
// img1, img2, img3, img4 created ...
// all img's are strings of RGBA values
// and look like [128,128,128,255,...]
var hasMotion;
hasMotion = motion.detect(img1);
console.log(hasMotion);
// > false
hasMotion = motion.detect(img2);
console.log(hasMotion);
// > true
hasMotion = motion.detect(img3, img4);
console.log(hasMotion);
// > false
Returns the last image.
var motion = new Motion();
console.log(motion.detect(img1));
// > false
console.log(motion.detect(img2));
// > true
console.log(img2 === motion.getLastImage());
// > true
Array
of Number
Array
of Number
Returns an image with detected motion as white pixels on a black background in the form of a flat array of RGBA numbers.
Inspiration for this library comes from Romuald Quantin's excellent write up on motion detection in Javascript.
FAQs
A tiny, performant animation library for the web
The npm package motion receives a total of 275,434 weekly downloads. As such, motion popularity was classified as popular.
We found that motion demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.