diff --git a/lib/opencv.js b/lib/opencv.js index bb1a694..5cda35d 100644 --- a/lib/opencv.js +++ b/lib/opencv.js @@ -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 # -*/ \ No newline at end of file +*/ + + +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); +}) + diff --git a/package.json b/package.json index 5ec3284..13d1fd3 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,11 @@ , "dependencies": { } , "version" : "0.0.2" + + , "dependencies": { + "buffers" : "0.1.1" + } + , "devDependencies": { "vows": "*" } diff --git a/test/smoke.js b/test/smoke.js index ab3d76b..92453c6 100644 --- a/test/smoke.js +++ b/test/smoke.js @@ -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(); \ No newline at end of file