diff --git a/index.html b/index.html
new file mode 100644
index 0000000..df554c1
--- /dev/null
+++ b/index.html
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/opencv.js b/lib/opencv.js
index 5cda35d..510f827 100644
--- a/lib/opencv.js
+++ b/lib/opencv.js
@@ -1,12 +1,12 @@
-var EventEmitter = require('events').EventEmitter
+var Stream = require('stream').Stream
, Buffers = require('buffers')
+ , util = require('util');
var bindings = require('./bindings')
var cv = module.exports = {};
cv.__proto__ = bindings;
-console.log(cv)
/*
# Matrix #
@@ -18,33 +18,38 @@ The matrix is one of opencv's most core datatypes.
var matrix = cv.Matrix.prototype;
matrix.faceDetect = function(classifier, opts, cb){
- var face_cascade = new opencv.CascadeClassifier("./examples/haarcascade_frontalface_alt.xml");
+ var face_cascade = new cv.CascadeClassifier("./examples/haarcascade_frontalface_alt.xml");
face_cascade.detectMultiScale(this, cb);
}
-/*
+matrix.inspect = function(){
+ var size = this.size() ? (this.size()[0] + 'x' + this.size()[1]) : '';
-# Image #
-
-*/
+ return "[Matrix " + size + " ]";
+}
cv.ImageStream = function(){
this.data = Buffers([])
+ this.writable = true
}
+util.inherits(cv.ImageStream, Stream);
var imagestream = cv.ImageStream.prototype;
-imagestream.__proto__ = EventEmitter.prototype;
-imagestream.on('data', function(buf){
+imagestream.write = function(buf){
this.data.push(buf)
- console.log("!!!<>");
-})
+ return true;
+}
+
+
+imagestream.end = function(b){
+ if (b)
+ imagestream.write.call(this,b);
-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);
-})
+
+ var im = cv.readImage(buf);
+ this.emit('load', im);
+}
diff --git a/smoketest.js b/smoketest.js
index 583aa5b..83060b8 100755
--- a/smoketest.js
+++ b/smoketest.js
@@ -1,6 +1,6 @@
var cv = require('./lib/opencv')
, assert = require('assert')
+ , fs =require('fs')
-console.log(cv.version)
-
-//console.log(cv.readImage("./examples/t2.jpg").toBuffer());
+//console.log(cv.version)
+
\ No newline at end of file
diff --git a/src/OpenCV.cc b/src/OpenCV.cc
index 953bcd4..d5f3999 100644
--- a/src/OpenCV.cc
+++ b/src/OpenCV.cc
@@ -33,7 +33,7 @@ OpenCV::ReadImage(const Arguments &args) {
width = args[0]->Uint32Value();
height = args[1]->Uint32Value();
- mat = *(new cv::Mat(width, height, CV_8UC1));
+ mat = *(new cv::Mat(width, height, CV_64FC1));
} else if (args[0]->IsString()) {
@@ -44,7 +44,7 @@ OpenCV::ReadImage(const Arguments &args) {
uint8_t *buf = (uint8_t *) Buffer::Data(args[0]->ToObject());
unsigned len = Buffer::Length(args[0]->ToObject());
- cv::Mat *mbuf = new cv::Mat(len, 1, CV_8UC1, buf);
+ cv::Mat *mbuf = new cv::Mat(len, 1, CV_64FC1, buf);
mat = cv::imdecode(*mbuf, -1);
if (mat.empty()){
diff --git a/test/smoke.js b/test/smoke.js
index 92453c6..0f257a8 100644
--- a/test/smoke.js
+++ b/test/smoke.js
@@ -172,8 +172,7 @@ vows.describe('Smoke Tests OpenCV').addBatch({
var cv = require('../lib/opencv')
, im = cv.readImage("./examples/mona.jpg")
, cascade = new cv.CascadeClassifier("./examples/haarcascade_frontalface_alt.xml");
-
- cascade.detectMultiScale(im, this.callback, 1.1, 2, [30, 30]);
+ cascade.detectMultiScale(im, this.callback)//, 1.1, 2, [30, 30]);
}
, "finds face": function(err, faces){
@@ -192,16 +191,19 @@ vows.describe('Smoke Tests OpenCV').addBatch({
, "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);
+ var s = new cv.ImageStream()
+ , self = this
+ s.on('load', function(im){
+ assert.ok(im)
+ assert.equal(im.empty(), false);
+ self.callback()
+ })
+ fs.createReadStream('./examples/mona.jpg').pipe(s);
}
, "loaded" : function(im){
- assert.ok(im);
- assert.equal(im.empty(), false);
+ //assert.ok(im)
+ //assert.equal(im.empty(), false);
}
}