python - 如何在 OpenCV 中获取图像的宽度和高度?

标签 python c++ opencv

我想获取图像的宽度和高度,我该如何在 OpenCV 中做到这一点?

例如:

Mat src = imread("path_to_image");
cout << src.width;

是吗?

最佳答案

你可以使用rowscols:

cout << "Width : " << src.cols << endl;
cout << "Height: " << src.rows << endl;

size():

cout << "Width : " << src.size().width << endl;
cout << "Height: " << src.size().height << endl;

大小

cout << "Width : " << src.size[1] << endl;
cout << "Height: " << src.size[0] << endl;

关于python - 如何在 OpenCV 中获取图像的宽度和高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32971241/

相关文章:

适用于 Windows 的 Python 程序可执行文件

python - Django 测试 : no data in temporary database file

c++ - 类中成员声明的重新排序规则

python - 如何在图像的人脸/ body 区域中检测太阳镜

opencv - 使用Cygwin编译OpenCV Android

python - 提高图像中字母的质量

python - 在 python 抓取器中使用装饰器时遇到问题

python - 应用于矩阵的 fft/fft2 的返回值有什么区别?

c++ - 一个好的数学 vector/矩阵类/结构可以为 C++ 下载?

c++ - 我应该选择哪个 C++ 信号/插槽库?