如何计算图像的分辨率

How to calculate the resolution of an image?

本文关键字:图像 分辨率 计算 何计算      更新时间:2023-10-16

如何使用OpenCV确定图像(垫格式)的分辨率(宽度x高度)?

我有一个接收许多图像的线程。一次一个。我想确定图像的分辨率,当线程收到图像时(以像素为单位获得宽度和高度的尺寸)。

像这样:

cv::Mat someMat;
int width;
int height;
width = someMat.cols;
height = someMat.rows;

或:

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

对于Mat mat,您可以简单地使用以下方法来获取其尺寸(宽度和高度):

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