node-opencv
node-opencv copied to clipboard
error in use toBuffer()
when modifying example mat-put.js
var opencv = require('../lib/opencv');
var mat = new opencv.Matrix(225,225,opencv.Constants.CV_8UC3); //
//var buf = Buffer(225*225*3).fill(0);
var buf = mat.toBuffer();
console.log("length-", buf.length);
for(var i=0;i<buf.length;i++){
buf[i] = (i%2===1)?0:255;
}
mat.put(buf);
var window = new opencv.NamedWindow('Mat-Put', 0);
window.show(mat);
window.blockingWaitKey(0, 50);
setTimeout(function(){
// keep the windows 30sec open
},4000);
Always get different value of buf.length, but if use
var buf = Buffer(2252253).fill(0)
works perfectly.
Since I need to modify all pixels of MAT, LENGTH buffer must not be variable. Just NEED multiply two matrices...