Skip to content

Instantly share code, notes, and snippets.

@peterbraden
Created August 24, 2012 20:11
Show Gist options
  • Save peterbraden/3455116 to your computer and use it in GitHub Desktop.
Save peterbraden/3455116 to your computer and use it in GitHub Desktop.
Webcam Face Detection in 16 lines of Javascript
var cv = require('opencv')
new cv.VideoCapture(0).read(function(mat){
mat.resize(200,100)
mat.detectObject("./data/haarcascade_frontalface_alt.xml", {min : [30,30]}, function(err, faces){
for (var i=0;i<faces.length; i++){
var x = faces[i]
mat.ellipse(x.x + x.width/2, x.y + x.height/2, x.width/2, x.height/2);
}
console.log(faces.length ? (faces.length + " faces found") : "No faces")
mat.save('./out.jpg');
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment