Optical flow detection in JavaScript