This commit is contained in:
Peter Braden 2012-01-25 09:20:04 -08:00
parent d7873e2b4e
commit b0b036ff34
3 changed files with 58 additions and 6 deletions

View File

@ -1,19 +1,21 @@
var EventEmitter = require('events').EventEmitter
, Buffers = require('buffers')
var opencv = require('./bindings')
module.exports = opencv;
var bindings = require('./bindings')
var cv = module.exports = {};
cv.__proto__ = bindings;
console.log(cv)
/*
# Matrix #
The matrix is one of opencv's most core datatypes.
*/
var matrix = opencv.Matrix.prototype;
matrix.__proto__ = EventEmitter.prototype;
var matrix = cv.Matrix.prototype;
matrix.faceDetect = function(classifier, opts, cb){
var face_cascade = new opencv.CascadeClassifier("./examples/haarcascade_frontalface_alt.xml");
@ -24,4 +26,25 @@ matrix.faceDetect = function(classifier, opts, cb){
# Image #
*/
*/
cv.ImageStream = function(){
this.data = Buffers([])
}
var imagestream = cv.ImageStream.prototype;
imagestream.__proto__ = EventEmitter.prototype;
imagestream.on('data', function(buf){
this.data.push(buf)
console.log("!!!<>");
})
imagestream.on('end', function(){
var buf = this.data.toBuffer();
//var im = opencv.readImage(buf);
console.log(this.data.length, buf.length);
//this.emit('onload', im);
})

View File

@ -5,6 +5,11 @@
, "dependencies": {
}
, "version" : "0.0.2"
, "dependencies": {
"buffers" : "0.1.1"
}
, "devDependencies": {
"vows": "*"
}

View File

@ -186,4 +186,28 @@ vows.describe('Smoke Tests OpenCV').addBatch({
}
, "ImageStream" : {
topic : require('../lib/opencv')
, "pipe" : {
topic : function(cv){
console.log("!!!")
var s = new cv.ImageStream();
console.log("***");
s.on('load', this.callback)
fs.open('./examples/mona.jpg').pipe(s);
}
, "loaded" : function(im){
assert.ok(im);
assert.equal(im.empty(), false);
}
}
}
}).run();