当前位置: 首页 > 面试题库 >

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

岳浩宕
2023-03-14
问题内容

我想获取图像的宽度和高度,如何在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;


 类似资料: