如何从opencv node.js库获取图像大小
我正在使用node.js open cv库,我想知道如何从看起来像矩阵对象的对象中获取图像的宽度和高度如何从opencv node.js库获取图像大小,node.js,opencv,Node.js,Opencv,我正在使用node.js open cv库,我想知道如何从看起来像矩阵对象的对象中获取图像的宽度和高度 cv.readImage("./sample.jpg", function(err, im){ var width = im.width;// this part breaks, how do I get width and height? }); 方法是size() e、 g 变量宽度=im.大小[0] 使用矩阵上的width()和height()方法: im.width() im.
cv.readImage("./sample.jpg", function(err, im){
var width = im.width;// this part breaks, how do I get width and height?
});
方法是size()
e、 g
变量宽度=im.大小[0] 使用矩阵上的width()
和height()
方法:
im.width()
im.height()
不过要小心。很容易忘记使用括号,然后只需引用函数:
console.log(img.width) // [Function: width]
console.log(img.width + ''); // function width() { [native code] }
当然,在这些示例中很容易发现问题,但是如果您不只是记录宽度和高度,那么问题最初可能不会被注意到