Inferring movement by differntiating two consecutive frames of a video stream.
// main.js
differ.addEventListener('message', drawBlendImage);
differ.postMessage({
buffer: buffer,
data1: data1,
data2: data2,
sensitivity: .5,
width: blendWidth,
height: blendHeight
});
// differ.js (worker)
this.addEventListener('message', createDiffBuffer);
this.postMessage(buffer);
// Math.abs
function abs(value) {
return (value ^ (value >> 31)) - (value >> 31);
}
// main.js
blendImageData
.data
.set(
new Uint8ClampedArray(messageEvent.data)
);
var data = new Uint32Array(buffer);
data[i] =
(255 << 24) | // alpha
(delta << 16) | // blue
(delta << 8) | // green
delta; // red