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

发布于 2021-01-29 17:10:23

我想获取图像的宽度和高度,如何在OpenCV中实现呢?

例如:

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

是对的吗?

关注者
0
被浏览
170
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    您可以使用rowscols

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

    size()

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


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看