I needed this as well. I used this link to help me get to this answer.
How to take a snapshot of HTML5-JavaScript-based video player?
In tracking.js example (face_camera.html) I added this canvas:
<canvas id="snapshotCanvas" width="320" height="240"></canvas>
Then inside the onTrack event I added this:
tracker.on('track', function(event) {
context.clearRect(0, 0, canvas.width, canvas.height);
event.data.forEach(function(rect) {
context.strokeStyle = '#a64ceb';
context.strokeRect(rect.x, rect.y, rect.width, rect.height);
context.font = '11px Helvetica';
context.fillStyle = "#fff";
context.fillText('x: ' + rect.x + 'px', rect.x + rect.width + 5, rect.y + 11);
context.fillText('y: ' + rect.y + 'px', rect.x + rect.width + 5, rect.y + 22);
var snapshotContext = snapshotCanvas.getContext('2d');
//draw image to canvas. scale to target dimensions
snapshotContext.drawImage(video, 0, 0, video.width, video.height);
//convert to desired file format
var dataURI = snapshotCanvas.toDataURL('image/jpeg'); // can also use 'image/png'
//This dataURI is what you would use to get the actual image
console.log(dataURI);
});
});
A bit late but hope it helps someone.