Skip to content

Instantly share code, notes, and snippets.

View Keyes's full-sized avatar
🏠
Working from home

Julian Kern Keyes

🏠
Working from home
View GitHub Profile
let cv = require('opencv');
let fs = require('fs');
let Jimp = require('jimp');
const imageWidth = 640;
const imageHeight = 480;
const movementPadding = 10;
const pixelDiffThreshold = 50;
var diff = new cv.Matrix(imageWidth, imageHeight);
/*
* Motion detection with nodeJS
*
* You'll need node-canvas: https://github.com/Automattic/node-canvas
*/
var Canvas = require('canvas'),
Image = Canvas.Image,
canvas = new Canvas(640, 480),
diffCanvas = new Canvas(640, 480),