update examples

This commit is contained in:
Peter Braden 2012-01-26 16:50:21 -08:00
parent 0c730cef5a
commit c93b9dcf14
3 changed files with 33 additions and 22 deletions

View File

@ -26,16 +26,16 @@ Or to build the repo:
### Face Detection
var im = cv.readImage("./examples/test.jpg")
im.faceDetect("./examples/haarcascade_frontalface_alt.xml", {}, function(err, faces){
for (var i=0;i<faces.length; i++){
var x = faces[i]
im.ellipse(x.x + x.width/2, x.y + x.height/2, x.width/2, x.height/2);
}
im.save('./out.jpg');
});
cv.readImage("./examples/test.jpg", function(err, im){
im.faceDetect("./examples/haarcascade_frontalface_alt.xml", {}, function(err, faces){
for (var i=0;i<faces.length; i++){
var x = faces[i]
im.ellipse(x.x + x.width/2, x.y + x.height/2, x.width/2, x.height/2);
}
im.save('./out.jpg');
});
})

View File

@ -26,18 +26,18 @@ var http = require('http')
request({uri:url, encoding:'binary'}, function(err, r, body){
if (err) throw err;
var im = new cv.readImage(new Buffer(body, 'binary'));
im.faceDetect(im, {}, function(err, faces){
for (var i=0;i<faces.length; i++){
var x = faces[i]
im.ellipse(x.x + x.width/2, x.y + x.height/2, x.width/2, x.height/2);
}
cv.readImage(new Buffer(body, 'binary'), function(err, im){
im.faceDetect(im, {}, function(err, faces){
for (var i=0;i<faces.length; i++){
var x = faces[i]
im.ellipse(x.x + x.width/2, x.y + x.height/2, x.width/2, x.height/2);
}
//console.log(faces);
resp.writeHead(200, {'Content-Type': 'image/jpeg'});
resp.end(im.toBuffer());
});
//console.log(faces);
resp.writeHead(200, {'Content-Type': 'image/jpeg'});
resp.end(im.toBuffer());
});
});
})
} else {
request({uri:url || 'http://google.com'}).pipe(resp)

View File

@ -3,4 +3,15 @@ var cv = require('./lib/opencv')
, fs =require('fs')
//console.log(cv.version)
cv.readImage("./examples/mona.jpg", function(err, im){
im.faceDetect("./examples/haarcascade_frontalface_alt.xml", {}, function(err, faces){
for (var i=0;i<faces.length; i++){
var x = faces[i]
im.ellipse(x.x + x.width/2, x.y + x.height/2, x.width/2, x.height/2);
}
im.save('./out.jpg');
});
})