AgentSmith891
AgentSmith891

Reputation: 5

How to calculate the resolution of an image?

How to determine the resolution (Width x Height) of an image (Mat format) with OpenCV?

I have a thread that receives many images..one at time. I want to determine the resolution of an image, when the thread receives it (to obtain dimension of width and height in pixel).

Upvotes: 0

Views: 1211

Answers (2)

Dima Maligin
Dima Maligin

Reputation: 1492

Like so:

cv::Mat someMat;
int width;
int height;

width = someMat.cols;
height = someMat.rows;

or:

width = someMat.size().width;
height = someMat.size().height;

Upvotes: 2

herohuyongtao
herohuyongtao

Reputation: 50717

For a Mat mat, you can simply use the following to get its dimension (width and height):

int width = mat.cols;
int height = mat.rows;

Upvotes: 2

Related Questions