Click Start/Stop button to start or stop the video.
The videoInput is a <video> element used as input. The canvasOutput is a <canvas> element used as output.
We get a 2-channel array with optical flow vectors, (u,v). We find their magnitude and direction. We color code the result for better visualization. Direction corresponds to Hue value of the image. Magnitude corresponds to Value plane.
The code of <textarea> will be executed when video is started.
You can modify the code to investigate more.