Skip to content

Instantly share code, notes, and snippets.

@peterbraden
Created January 26, 2012 04:08
Show Gist options
  • Save peterbraden/1680920 to your computer and use it in GitHub Desktop.
Save peterbraden/1680920 to your computer and use it in GitHub Desktop.
var s = new cv.ImageStream();
fs.createReadStream('./examples/mona.jpg').pipe(s);
// ---
cv.ImageStream = function(){
this.data = Buffers([])
}
util.inherits(cv.ImageStream, Stream);
var imagestream = cv.ImageStream.prototype;
imagestream.write = function(buf){
console.log(">>>>>>>>>>", buf);
this.data.push(buf)
return true;
}
imagestream.writeable = true;
imagestream.end = function(b){
if (b)
imagestream.write.call(this,b);
var buf = this.data.toBuffer();
console.log(this.data, arguments, ">>>", buf.length);
//var im = cv.readImage(buf);
//this.emit('load', im);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment