mirror of
https://github.com/peterbraden/node-opencv.git
synced 2025-12-08 19:45:55 +00:00
hacking around vows bug
This commit is contained in:
parent
b0b036ff34
commit
bbd5c06b31
11
index.html
Normal file
11
index.html
Normal file
@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/documentup/latest.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
DocumentUp.document("username/repository");
|
||||
</script>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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()){
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user