需要在人脸检测中添加自动捕获/快照的帮助。使用tracking.js中的这个示例:
https://github.com/eduardolundgren/tracking.js/blob/master/examples/face_camera.html http://trackingjs.com/examples/face_camera.html
任何想法都将得到极大的赞赏。谢谢!
发布于 2016-09-27 01:28:48
我也需要这个。我使用这个链接来帮助我找到这个答案。
How to take a snapshot of HTML5-JavaScript-based video player?
在tracking.js示例(face_camera.html)中,我添加了以下画布:
<canvas id="snapshotCanvas" width="320" height="240"></canvas>然后在onTrack事件中,我添加了以下内容:
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);
});
});有点晚了,但希望能帮助到一些人。
https://stackoverflow.com/questions/33885457
复制相似问题