Skip to content

Instantly share code, notes, and snippets.

@datitran
Created December 6, 2016 14:29
Show Gist options
  • Save datitran/43227a09a289362d06dd02a3501c8c6e to your computer and use it in GitHub Desktop.
Save datitran/43227a09a289362d06dd02a3501c8c6e to your computer and use it in GitHub Desktop.
grabFrame: function() {
var self = this;
this.canvasCtx.drawImage(this.video, 0, 0, this.canvas.width, this.canvas.height);
this.canvas.toBlob(function(imageData) {
var postImageReq = new XMLHttpRequest();
postImageReq.open("POST", "/prediction", true);
postImageReq.responseType = "json";
postImageReq.onload = function(event) {
var faces = postImageReq.response.faces;
self.drawFaces(faces);
self.scheduleFrameGrab();
};
postImageReq.send(imageData);
}, "image/jpeg", 70);
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment