Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从opencv node.js库获取图像大小_Node.js_Opencv - Fatal编程技术网

如何从opencv node.js库获取图像大小

如何从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.

我正在使用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.height()
不过要小心。很容易忘记使用括号,然后只需引用函数:

console.log(img.width) // [Function: width]
console.log(img.width + ''); // function width() { [native code] }
当然,在这些示例中很容易发现问题,但是如果您不只是记录宽度和高度,那么问题最初可能不会被注意到