Merge pull request #178 from marcbachmann/cleanup-examples

Cleanup of examples
This commit is contained in:
Peter Braden 2014-10-07 08:33:07 +02:00
commit 10bc08364f
36 changed files with 317 additions and 354 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ npm-debug.log
out*.jpg out*.jpg
out*.png out*.png
examples/*.avi examples/*.avi
examples/tmp/*

View File

@ -28,7 +28,7 @@ $ node-gyp rebuild
### Face Detection ### Face Detection
```javascript ```javascript
cv.readImage("./examples/test.jpg", function(err, im){ cv.readImage("./examples/files/mona.png", function(err, im){
im.detectObject(cv.FACE_CASCADE, {}, function(err, faces){ im.detectObject(cv.FACE_CASCADE, {}, function(err, faces){
for (var i=0;i<faces.length; i++){ for (var i=0;i<faces.length; i++){
var x = faces[i] var x = faces[i]
@ -80,7 +80,7 @@ s.on('load', function(matrix){
... ...
}) })
fs.createReadStream('./examples/test.jpg').pipe(s); fs.createReadStream('./examples/files/mona.png').pipe(s);
``` ```
If however, you have a series of images, and you wish to stream them into a If however, you have a series of images, and you wish to stream them into a

View File

@ -1,20 +0,0 @@
var cv = require('../lib/opencv');
var COLOR = [0, 255, 0]; //default red
var thickness = 2; // default 1
cv.readImage('./mona.png', function(err, im) {
im.detectObject('../data/haarcascade_frontalface_alt2.xml', {}, function(err, faces) {
for(var k = 0; k < faces.length; k++) {
face = faces[k];
im.rectangle([face.x, face.y], [face.x + face.width, face.y + face.height], COLOR, 2);
}
im.save('/tmp/salida.png');
});
});

View File

@ -1,16 +1,14 @@
var cv = require('../lib/opencv'); var cv = require('../lib/opencv');
cv.readImage("./files/mona.png", function(err, orig) {
if (err) throw err;
cv.readImage("./mona.png", function(err, orig) { cv.readImage("./files/over_text.png", function(err, over_text) {
if (err) throw err;
cv.readImage("./over_text.png", function(err, over_text) {
var result = new cv.Matrix(orig.width(), orig.height()); var result = new cv.Matrix(orig.width(), orig.height());
result.addWeighted(orig, 0.7, over_text, 0.9); result.addWeighted(orig, 0.7, over_text, 0.9);
result.save("/tmp/weighted.png"); result.save("./tmp/weighted.png");
console.log('Image saved to ./tmp/weighted.png');
}); });
}); });

View File

@ -1,13 +1,12 @@
var cv = require('../lib/opencv'); var cv = require('../lib/opencv');
var camera = new cv.VideoCapture(0); var camera = new cv.VideoCapture(0);
var window = new cv.NamedWindow('Video', 0)
setInterval(function() { setInterval(function() {
camera.read(function(err, im) { camera.read(function(err, im) {
if (err) throw err;
//im.save('/tmp/cam.png'); window.show(im);
window.blockingWaitKey(0, 50);
}); });
}, 20);
}, 1000);

18
examples/car-detection.js Normal file
View File

@ -0,0 +1,18 @@
var cv = require('../lib/opencv');
cv.readImage("./files/car1.jpg", function(err, im){
if (err) throw err;
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
im.detectObject("../data/hogcascade_cars_sideview.xml", {}, function(err, cars){
if (err) throw err;
for (var i=0; i < cars.length; i++){
var x = cars[i];
im.rectangle([x.x, x.y], [x.width, x.height]);
}
im.save('./tmp/car-detection.jpg');
console.log('Image saved to ./tmp/car-detection.jpg');
});
});

View File

@ -1,16 +0,0 @@
var cv = require('../lib/opencv')
, assert = require('assert')
, fs =require('fs')
cv.readImage("./car1.jpg", function(err, im){
im.detectObject("../data/hogcascade_cars_sideview.xml", {}, function(err, cars){
for (var i=0;i<cars.length; i++){
var x = cars[i];
im.rectangle([x.x, x.y], [x.width, x.height]);
}
im.save('./cars.jpg');
});
});

14
examples/color-filter.js Normal file
View File

@ -0,0 +1,14 @@
var cv = require('../lib/opencv');
// (B)lue, (G)reen, (R)ed
var lower_threshold = [46, 57, 83];
var upper_threshold = [80, 96, 115];
cv.readImage('./files/coin1.jpg', function(err, im) {
if (err) throw err;
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
im.inRange(lower_threshold, upper_threshold);
im.save('./tmp/coin_detected.jpg');
console.log('Image saved to ./tmp/coin_detected.jpg');
});

View File

@ -1,12 +0,0 @@
var cv = require('../lib/opencv');
// (B)lue, (G)reen, (R)ed
var lower_threshold = [46, 57, 83];
var upper_threshold = [80, 96, 115];
cv.readImage('./coin1.jpg', function(err, im) {
im.inRange(lower_threshold, upper_threshold);
im.save('./coin_detected.jpg');
});

View File

@ -9,10 +9,14 @@ var GREEN = [0, 255, 0]; //B, G, R
var WHITE = [255, 255, 255]; // B, G, R var WHITE = [255, 255, 255]; // B, G, R
var RED = [0, 0, 255]; // B, G, R var RED = [0, 0, 255]; // B, G, R
cv.readImage('./stuff.png', function(err, im) { cv.readImage('./files/stuff.png', function(err, im) {
if (err) throw err;
var width = im.width();
var height = im.height();
if (width < 1 || height < 1) throw new Error('Image has no size');
var big = new cv.Matrix(im.height(), im.width()); var big = new cv.Matrix(height, width);
var all = new cv.Matrix(im.height(), im.width()); var all = new cv.Matrix(height, width);
im.convertGrayscale(); im.convertGrayscale();
im_canny = im.copy(); im_canny = im.copy();
@ -35,7 +39,7 @@ cv.readImage('./stuff.png', function(err, im) {
all.drawAllContours(contours, WHITE); all.drawAllContours(contours, WHITE);
big.save('./tmp/big.png');
big.save('./big.png'); all.save('./tmp/all.png');
all.save('./all.png'); console.log('Image saved to ./tmp/big.png && ./tmp/all.png');
}); });

21
examples/convert-image.js Executable file
View File

@ -0,0 +1,21 @@
var cv = require('../lib/opencv');
cv.readImage('./files/mona.png', function(err, im) {
if (err) throw err;
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
img_hsv = im.copy();
img_gray = im.copy();
img_hsv.convertHSVscale();
img_gray.convertGrayscale();
im.save('./tmp/nor.png');
img_hsv.save('./tmp/hsv.png');
img_gray.save('./tmp/gray.png');
img_crop = im.crop(50,50,250,250);
img_crop.save('./tmp/crop.png');
console.log('Image saved to ./tmp/{crop|nor|hsv|gray}.png');
});

View File

@ -1,24 +0,0 @@
var cv = require('../lib/opencv');
cv.readImage("./mona.png", function(err, im) {
img_hsv = im.copy();
img_gray = im.copy();
img_hsv.convertHSVscale();
img_gray.convertGrayscale();
console.log(img_gray.pixel(100,100));
im.save("/tmp/nor.png");
img_hsv.save("/tmp/hsv.png");
img_gray.save("/tmp/gray.png");
img_crop = im.crop(50,50,250,250);
img_crop.save("crop.png");
console.log("Guardado");
});

View File

@ -1,9 +1,4 @@
#!/usr/bin/env node
//
// Detects triangles and quadrilaterals // Detects triangles and quadrilaterals
//
var cv = require('../lib/opencv'); var cv = require('../lib/opencv');
var lowThresh = 0; var lowThresh = 0;
@ -17,13 +12,16 @@ var GREEN = [0, 255, 0]; //B, G, R
var WHITE = [255, 255, 255]; // B, G, R var WHITE = [255, 255, 255]; // B, G, R
cv.readImage('./shapes.jpg', function(err, im) { cv.readImage('./files/shapes.jpg', function(err, im) {
if (err) throw err;
var out = new cv.Matrix(im.height(), im.width()); width = im.width()
height = im.height()
if (width < 1 || height < 1) throw new Error('Image has no size');
var out = new cv.Matrix(height, width);
im.convertGrayscale(); im.convertGrayscale();
im_canny = im.copy(); im_canny = im.copy();
im_canny.canny(lowThresh, highThresh); im_canny.canny(lowThresh, highThresh);
im_canny.dilate(nIters); im_canny.dilate(nIters);
@ -48,5 +46,6 @@ cv.readImage('./shapes.jpg', function(err, im) {
} }
} }
out.save('./out.png'); out.save('./tmp/detect-shapes.png');
console.log('Image saved to ./tmp/detect-shapes.png');
}); });

View File

@ -0,0 +1,22 @@
var cv = require('../lib/opencv');
var COLOR = [0, 255, 0]; // default red
var thickness = 2; // default 1
cv.readImage('./files/mona.png', function(err, im) {
if (err) throw err;
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
im.detectObject('../data/haarcascade_frontalface_alt2.xml', {}, function(err, faces) {
if (err) throw err;
for (var i = 0; i < faces.length; i++) {
face = faces[i];
im.rectangle([face.x, face.y], [face.x + face.width, face.y + face.height], COLOR, 2);
}
im.save('./tmp/face-detection-rectangle.png');
console.log('Image saved to ./tmp/face-detection-rectangle.png');
});
});

18
examples/face-detection.js Executable file
View File

@ -0,0 +1,18 @@
var cv = require('../lib/opencv');
cv.readImage("./files/mona.png", function(err, im){
if (err) throw err;
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
im.detectObject("../data/haarcascade_frontalface_alt.xml", {}, function(err, faces){
if (err) throw err;
for (var i = 0; i < faces.length; i++){
var face = faces[i];
im.ellipse(face.x + face.width / 2, face.y + face.height / 2, face.width / 2, face.height / 2);
}
im.save('./tmp/face-detection.png');
console.log('Image saved to ./tmp/face-detection.png');
});
});

View File

@ -1,46 +1,30 @@
/* // Face recognition proxy
var http = require('http'),
Face recognition proxy request = require('request'),
cv = require('../lib/opencv');
*/
var http = require('http')
, request = require('request')
, cv = require('../lib/opencv')
, face_cascade = new cv.CascadeClassifier("./data/haarcascade_frontalface_alt.xml")
http.createServer(function(req, resp){ http.createServer(function(req, resp){
var url = req.url.slice(1); var url = req.url.slice(1);
console.log(url);
if (url.indexOf('http') != 0){
return request({uri:'http://google.com'}).pipe(resp)
}
// TODO make sure image
if (url.indexOf(".jpg", url.length - 4) !== -1 ||
url.indexOf(".png", url.length - 4) !== -1){
request({uri:url, encoding:'binary'}, function(err, r, body){ request({uri:url, encoding:'binary'}, function(err, r, body){
if (err) throw err; if (err) return resp.end(err.stack);
if (!/image\//.test(r.headers['content-type'])) return resp.end('Not an image');
cv.readImage(new Buffer(body, 'binary'), function(err, im){ cv.readImage(new Buffer(body, 'binary'), function(err, im){
im.faceDetect(im, {}, function(err, faces){ if (err) return resp.end(err.stack);
if (im.width() < 1 || im.height() < 1) return resp.end('Image has no size');
im.detectObject('../data/haarcascade_frontalface_alt.xml', {}, function(err, faces) {
if (err) return resp.end(err.stack);
for (var i = 0; i < faces.length; i++){ for (var i = 0; i < faces.length; i++){
var x = faces[i] var face = faces[i];
im.ellipse(x.x + x.width/2, x.y + x.height/2, x.width/2, x.height/2); im.ellipse(face.x + face.width / 2, face.y + face.height / 2, face.width / 2, face.height / 2);
} }
//console.log(faces);
resp.writeHead(200, {'Content-Type': 'image/jpeg'}); resp.writeHead(200, {'Content-Type': 'image/jpeg'});
resp.end(im.toBuffer()); resp.end(im.toBuffer());
}); });
}); });
}) });
} else {
request({uri:url || 'http://google.com'}).pipe(resp)
}
}).listen(1901)
}).listen(3000, function(){ console.log('Listening on http://localhost:3000'); })

View File

@ -1,18 +0,0 @@
var cv = require('../lib/opencv')
, assert = require('assert')
, fs =require('fs')
//console.log(cv.version)
cv.readImage("./mona.png", function(err, im){
im.detectObject("./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.png');
});
});

View File

Before

Width:  |  Height:  |  Size: 270 KiB

After

Width:  |  Height:  |  Size: 270 KiB

View File

Before

Width:  |  Height:  |  Size: 992 KiB

After

Width:  |  Height:  |  Size: 992 KiB

View File

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 518 KiB

After

Width:  |  Height:  |  Size: 518 KiB

View File

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 111 KiB

View File

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 116 KiB

View File

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 186 KiB

View File

@ -2,16 +2,18 @@ var path = require('path'),
cv = require('../lib/opencv'); cv = require('../lib/opencv');
// When opening a file, the full path must be passed to opencv // When opening a file, the full path must be passed to opencv
var vid = new cv.VideoCapture(path.join(__dirname, "motion.mov")); var vid = new cv.VideoCapture(path.join(__dirname, 'files', 'motion.mov'));
vid.read(function(err, mat){ vid.read(function(err, mat){
var track = new cv.TrackedObject(mat, [420, 110, 490, 170], {channel: "value"}); if (err) throw err;
var track = new cv.TrackedObject(mat, [420, 110, 490, 170], {channel: 'value'});
var x = 0; var x = 0;
var iter = function(){ var iter = function(){
vid.read(function(err, m2){ vid.read(function(err, m2){
x++; x++;
var rec = track.track(m2) var rec = track.track(m2)
console.log(">>", x, ":" , rec) console.log('>>', x, ':' , rec)
if (x % 10 == 0){ if (x % 10 == 0){
m2.rectangle([rec[0], rec[1]], [rec[2], rec[3]]) m2.rectangle([rec[0], rec[1]], [rec[2], rec[3]])
// m2.save('./out-motiontrack-' + x + '.jpg') // m2.save('./out-motiontrack-' + x + '.jpg')
@ -22,4 +24,3 @@ vid.read(function(err, mat){
} }
iter(); iter();
}) })

View File

@ -1,9 +1,4 @@
#!/usr/bin/env node
//
// Finds quadrilaterals and fills them with an X // Finds quadrilaterals and fills them with an X
//
var cv = require('../lib/opencv'); var cv = require('../lib/opencv');
var lowThresh = 0; var lowThresh = 0;
@ -17,8 +12,9 @@ var RED = [0, 0, 255]; //B, G, R
var GREEN = [0, 255, 0]; //B, G, R var GREEN = [0, 255, 0]; //B, G, R
var WHITE = [255, 255, 255]; //B, G, R var WHITE = [255, 255, 255]; //B, G, R
cv.readImage('./files/quads.jpg', function(err, im) {
cv.readImage('./quads.jpg', function(err, im) { if (err) throw err;
if (im.width() < 1 || im.height() < 1) throw new Error('Image has no size');
var out = im.copy(); var out = im.copy();
@ -51,5 +47,6 @@ cv.readImage('./quads.jpg', function(err, im) {
out.line([points[1].x,points[1].y], [points[3].x, points[3].y], RED); out.line([points[1].x,points[1].y], [points[3].x, points[3].y], RED);
} }
out.save('./out.png'); out.save('./tmp/quad-crosses.png');
console.log('Image saved to ./tmp/quad-crosses.png');
}); });

View File

@ -1,27 +1,20 @@
var cv = require('../lib/opencv'); var cv = require('../lib/opencv');
cv.readImage("./files/mona.png", function(err, im) {
cv.readImage("./mona.png", function(err, im) { salt(im, 1000);
salt(im, 3000); im.save("./tmp/salt.png");
im.save("/tmp/salt.png"); console.log('Image saved to ./tmp/salt.png');
}); });
function salt(img, n) { function salt(img, n) {
var channels;
if ((channels = img.channels()) != 3) return console.log('Image has only %s Channel. It\'s not possible to salt this image.', channels)
var width = img.width();
if (img.channels() == 1) { var height = img.height();
for(var i = 0; i < n; i ++) {
console.log("1 Canales"); x = Math.random() * width;
} else if (img.channels() == 3) { y = Math.random() * height;
img.set(y, x, 255);
for(k = 0; k < n; k ++) {
i = Math.random() * img.width();
j = Math.random() * img.height();
img.set(j, i, 255);
} }
} }
}

View File

@ -1,19 +1,15 @@
var cv = require('../lib/opencv') var cv = require('../lib/opencv');
var vid = new cv.VideoCapture(0);
var vid = new cv.VideoCapture(0)
var snap = function(){
vid.read(function(err, im){ vid.read(function(err, im){
if (err) throw err;
im.detectObject(cv.FACE_CASCADE, {}, function(err, faces){ im.detectObject(cv.FACE_CASCADE, {}, function(err, faces){
if (err) throw err;
if (!faces.length) return console.log("No Faces");
if (!faces){ var face = faces[0];
console.log("No Faces") var ims = im.size();
return;
}
var face = faces[0]
, ims = im.size()
var im2 = im.roi(face.x, face.y, face.width, face.height) var im2 = im.roi(face.x, face.y, face.width, face.height)
/* /*
im.adjustROI( im.adjustROI(
@ -22,10 +18,7 @@ var snap = function(){
, -face.x , -face.x
, (face.x + face.width) - ims[1]) , (face.x + face.width) - ims[1])
*/ */
im2.save('out.jpg') im2.save('./tmp/take-face-pics.jpg')
console.log('Image saved to ./tmp/take-face-pics.jpg');
}) })
}); });
}
snap()

0
examples/tmp/.gitkeep Normal file
View File

16
examples/warp-image.js Normal file
View File

@ -0,0 +1,16 @@
var cv = require('../lib/opencv');
cv.readImage("./mona.png", function(err, im) {
if (err) throw err;
var width = im.width();
var height = im.height();
if (width < 1 || height < 1) throw new Error('Image has no size');
var srcArray = [0, 0, width, 0, width, height, 0, height];
var dstArray = [0, 0, width * 0.9, height * 0.1, width, height, width * 0.2, height * 0.8];
var xfrmMat = im.getPerspectiveTransform(srcArray, dstArray);
im.warpPerspective(xfrmMat, width, height, [255, 255, 255]);
im.save("./warp-image.png");
console.log('Image saved to ./tmp/warp-image.png');
});

View File

@ -1,23 +0,0 @@
var cv = require('../lib/opencv');
cv.readImage("./mona.png", function(err, im) {
var srcArray = [
0,0,
im.width(),0,
im.width(),im.height(),
0,im.height()];
var dstArray = [
0,0,
im.width()*.9,im.height()*.1,
im.width(),im.height(),
im.width()*.2,im.height()*.8];
var xfrmMat = im.getPerspectiveTransform(srcArray,dstArray);
img_warp = im.copy();
img_warp.warpPerspective(xfrmMat,im.width,im.height,[255,255,255]);
img_warp.save("/tmp/mona_warp.png");
});

View File

@ -20,9 +20,7 @@ cv.readImage("/Users/peterbraden/Downloads/orl_faces/s6/10.pgm", function(e, im)
*/ */
cv.readImage("examples/mona.png", function(e, mat){ cv.readImage("./examples/files/mona.png", function(e, mat){
var th = mat.threshold(200, 200, "Threshold to Zero Inverted"); var th = mat.threshold(200, 200, "Threshold to Zero Inverted");
th.save('out.png') th.save('./examples/tmp/out.png')
}) })

View File

@ -43,8 +43,8 @@ vows.describe('Smoke Tests OpenCV').addBatch({
, 'importing library multiple times is ok' : function(){ , 'importing library multiple times is ok' : function(){
var cv1 = require('../lib/opencv') var cv1 = require('../lib/opencv')
, cv2 = require('../lib/opencv') , cv2 = require('../lib/opencv')
cv1.readImage('./examples/mona.png', function(){}); cv1.readImage('./examples/files/mona.png', function(){});
cv2.readImage('./examples/mona.png', function(){}); cv2.readImage('./examples/files/mona.png', function(){});
} }
} }
@ -144,7 +144,7 @@ vows.describe('Smoke Tests OpenCV').addBatch({
} }
, "toBuffer": function(cv){ , "toBuffer": function(cv){
var buf = fs.readFileSync('./examples/mona.png') var buf = fs.readFileSync('./examples/files/mona.png')
cv.readImage(buf.slice(0), function(err, mat){ cv.readImage(buf.slice(0), function(err, mat){
var buf0 = mat.toBuffer() var buf0 = mat.toBuffer()
@ -157,7 +157,7 @@ vows.describe('Smoke Tests OpenCV').addBatch({
, "toBuffer Async": { , "toBuffer Async": {
topic: function(cv){ topic: function(cv){
var buf = fs.readFileSync('./examples/mona.png') var buf = fs.readFileSync('./examples/files/mona.png')
, cb = this.callback , cb = this.callback
cv.readImage(buf.slice(0), function(err, mat){ cv.readImage(buf.slice(0), function(err, mat){
var buff = mat.toBuffer(function(){ var buff = mat.toBuffer(function(){
@ -178,7 +178,7 @@ vows.describe('Smoke Tests OpenCV').addBatch({
var cv = require('../lib/opencv') var cv = require('../lib/opencv')
, cb = this.callback , cb = this.callback
cv.readImage("./examples/mona.png", function(err, im){ cv.readImage("./examples/files/mona.png", function(err, im){
im.detectObject(cv.FACE_CASCADE, {}, cb) im.detectObject(cv.FACE_CASCADE, {}, cb)
}) })
} }
@ -191,8 +191,8 @@ vows.describe('Smoke Tests OpenCV').addBatch({
} }
, ".absDiff and .countNonZero" : function(cv) { , ".absDiff and .countNonZero" : function(cv) {
cv.readImage("./examples/mona.png", function(err, im) { cv.readImage("./examples/files/mona.png", function(err, im) {
cv.readImage("./examples/mona.png", function(err, im2){ cv.readImage("./examples/files/mona.png", function(err, im2){
assert.ok(im); assert.ok(im);
assert.ok(im2); assert.ok(im2);
@ -226,7 +226,7 @@ vows.describe('Smoke Tests OpenCV').addBatch({
topic : require('../lib/opencv') topic : require('../lib/opencv')
, ".readImage from file": function(cv){ , ".readImage from file": function(cv){
cv.readImage("./examples/mona.png", function(err, im){ cv.readImage("./examples/files/mona.png", function(err, im){
assert.ok(im); assert.ok(im);
assert.equal(im.width(), 500); assert.equal(im.width(), 500);
assert.equal(im.height(), 756) assert.equal(im.height(), 756)
@ -235,7 +235,7 @@ vows.describe('Smoke Tests OpenCV').addBatch({
} }
, ".readImage from buffer" : function(cv){ , ".readImage from buffer" : function(cv){
cv.readImage(fs.readFileSync('./examples/mona.png'), function(err, im){ cv.readImage(fs.readFileSync('./examples/files/mona.png'), function(err, im){
assert.ok(im); assert.ok(im);
assert.equal(im.width(), 500); assert.equal(im.width(), 500);
assert.equal(im.height(), 756) assert.equal(im.height(), 756)
@ -259,7 +259,7 @@ vows.describe('Smoke Tests OpenCV').addBatch({
var cv = require('../lib/opencv') var cv = require('../lib/opencv')
, self = this , self = this
cv.readImage("./examples/mona.png", function(err, im){ cv.readImage("./examples/files/mona.png", function(err, im){
cascade = new cv.CascadeClassifier("./data/haarcascade_frontalface_alt.xml"); cascade = new cv.CascadeClassifier("./data/haarcascade_frontalface_alt.xml");
cascade.detectMultiScale(im, self.callback)//, 1.1, 2, [30, 30]); cascade.detectMultiScale(im, self.callback)//, 1.1, 2, [30, 30]);
}) })
@ -289,7 +289,7 @@ vows.describe('Smoke Tests OpenCV').addBatch({
assert.equal(im.empty(), false); assert.equal(im.empty(), false);
self.callback() self.callback()
}) })
fs.createReadStream('./examples/mona.png').pipe(s); fs.createReadStream('./examples/files/mona.png').pipe(s);
} }
, "loaded" : function(im){ , "loaded" : function(im){
@ -305,7 +305,7 @@ vows.describe('Smoke Tests OpenCV').addBatch({
, "write" : { , "write" : {
topic: function(cv){ topic: function(cv){
var s = new cv.ImageStream() var s = new cv.ImageStream()
, im = fs.readFileSync('./examples/mona.png') , im = fs.readFileSync('./examples/files/mona.png')
, self = this; , self = this;
s.on('data', function(m){ s.on('data', function(m){
@ -331,8 +331,8 @@ vows.describe('Smoke Tests OpenCV').addBatch({
var cv = require('../lib/opencv') var cv = require('../lib/opencv')
, self = this , self = this
cv.readImage('./examples/coin1.jpg', function(e, im){ cv.readImage('./examples/files/coin1.jpg', function(e, im){
cv.readImage('./examples/coin2.jpg', function(e, im2){ cv.readImage('./examples/files/coin2.jpg', function(e, im2){
self.callback(im, im2, cv) self.callback(im, im2, cv)
}) })
}) })
@ -356,7 +356,7 @@ vows.describe('Smoke Tests OpenCV').addBatch({
var cv = require('../lib/opencv') var cv = require('../lib/opencv')
, self = this , self = this
cv.readImage('./examples/coin1.jpg', function(e, im){ cv.readImage('./examples/files/coin1.jpg', function(e, im){
self.callback(null, im); self.callback(null, im);
}); });
}, },
@ -381,7 +381,7 @@ vows.describe('Smoke Tests OpenCV').addBatch({
im.putText("Some text", 0, y += 20, font, [rnd(), rnd(), rnd()]); im.putText("Some text", 0, y += 20, font, [rnd(), rnd(), rnd()]);
}); });
im.save("./examples/coin1-with-text.jpg"); im.save("./examples/tmp/coin1-with-text.jpg");
} }
} }