'how to get image size from opencv node.js library
I'm using the node.js open cv library and I was wondering how to get the image width and height from what looks like a Matrix object
cv.readImage("./sample.jpg", function(err, im){
var width = im.width;// this part breaks, how do I get width and height?
});
Solution 1:[1]
Use the width() and height() methods on the matrix:
im.width()
im.height()
Be careful though. It's easy to forget to use the parentheses, and then you will simply be referencing the function:
console.log(img.width) // [Function: width]
console.log(img.width + ''); // function width() { [native code] }
Of course, it's easy to spot the problem in these examples, but if you're not just logging the width and height, the issues may initially go unnoticed.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nateowami |
