unit test for imagestream

This commit is contained in:
Peter Braden 2013-02-26 16:23:14 -08:00
parent 0cb436e930
commit 24f255a161
2 changed files with 45 additions and 0 deletions

View File

@ -77,9 +77,31 @@ util.inherits(cv.ImageStream, Stream);
var imagestream = cv.ImageStream.prototype;
imagestream.write = function(buf){
var self = this;
cv.readImage(buf, function(err, matrix){
self.emit('data', matrix);
});
}
// Object detect stream
cv.ObjectDetectionStream = function(cascade, opts){
this.classifier = new cv.CascadeClassifier(cascade);
this.opts = opts
}
util.inherits(cv.ObjectDetectionStream, Stream);
var ods = cv.ObjectDetectionStream.prototype;
ods.write = function(m){
var self = this;
this.classifier.detectMultiScale(m,
function(e, objs){
if (e) { throw e }
self.emit('data', objs);
}
, this.opts.scale, this.opts.neighbors
, this.opts.min && this.opts.min[0], this.opts.min && this.opts.min[1]);
}

View File

@ -272,6 +272,29 @@ vows.describe('Smoke Tests OpenCV').addBatch({
}
}
, "ImageStream" :{
topic : require('../lib/opencv')
, "write" : {
topic: function(cv){
var s = new cv.ImageStream()
, im = fs.readFileSync('./examples/mona.png')
, self = this;
s.on('data', function(m){
self.callback(null, m)
})
s.write(im);
}
, "receives data" : function(mat){
assert.deepEqual(mat.size(), [756,500])
}
}
}
, "ObjectDetectionStream" :{
topic : require('../lib/opencv')
}
, "CamShift" : {