-
Notifications
You must be signed in to change notification settings - Fork 0
setupVideoCallback
Matt Ellen edited this page Nov 14, 2015
·
5 revisions
Takes a video element, a callback and a number.
Returns nothing.
The number is the time, in milliseconds, between frames.
The callback takes no arguments and returns nothing.
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var vid = document.getElementById('vid');
function capture()
{
canvas.width = vid.clientWidth;
canvas.height = vid.clientHeight;
ctx.drawImage(vid, 0, 0);
var data = ctx.getImageData(0, 0, vid.clientWidth, vid.clientHeight);
var edges = jsia.detectEdgePixels(data, 32);
ctx.putImageData(edges, 0, 0);
}
jsia.setupVideoCallback(vid, capture, 10);
//Sets up the capture function to be called every ten milliseconds
//to read the information of the current video from in the vid object.
//(The capture function takes the image data, detects the edge pixels
//and then displays them on the canvas.)