openCV常用操作

2018-06-03  本文已影响0人  lhdoeo

const cv = require('opencv4nodejs');

创建矩阵

const rows = 100; // height
const cols = 100; // width

var emptyMat = new cv.Mat(rows, cols, cv.CV_8UC3);
8位无符号3通道矩阵,就是常见的RGB数组[0-255,0-255,0-255]

var whiteMat = new cv.Mat(rows, cols, cv.CV_8UC1, 255);
var blueMat = new cv.Mat(rows, cols, cv.CV_8UC3, [255, 0, 0]);

矩阵、向量操作

const mat0 = new cv.Mat(...);
const mat1 = new cv.Mat(...);

访问矩阵、向量数据

const matBGR = new cv.Mat(..., cv.CV_8UC3);
const matGray = new cv.Mat(..., cv.CV_8UC1);

IO

const buffer = Buffer.from(base64data,'base64');
const image = cv.imdecode(buffer);

上一篇下一篇

猜你喜欢

热点阅读