Created
January 11, 2013 17:15
-
-
Save maxired/4512404 to your computer and use it in GitHub Desktop.
processing a video in haar.js in Node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cv = require('opencv'); | |
var Canvas = require('canvas'), | |
fs = require('fs'), | |
HAAR = require('./src/haar-detector'); | |
var loaded=false; | |
var detector = require('./cascades/haarcascade_frontalface_alt').haarcascade_frontalface_alt; | |
var vid = new cv.VideoCapture(__dirname +"/../../120308.mp4") | |
var Image = Canvas.Image; | |
var looping =function(){ | |
vid.read(function(mat){ | |
var img = new Image; | |
img.onload = function(){ | |
new HAAR.Detector(detector).image(img, 1, new Canvas()).complete(function() { | |
//processing done | |
console.log("processing done", JSON.stringify(this.objects)) | |
looping(); | |
}).detect(1, 1.25, 0.1, 1, true); | |
} | |
img.src = mat.toBuffer(); | |
}) | |
} | |
looping(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment