mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
unit test for imagestream
This commit is contained in:
parent
0cb436e930
commit
24f255a161
@ -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]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
23
test/unit.js
23
test/unit.js
@ -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" : {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user