【问题标题】:How to calculate the resolution of an image?如何计算图像的分辨率?
【发布时间】:2014-02-18 16:08:19
【问题描述】:

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

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

【问题讨论】:

    标签: c++ visual-c++ opencv


    【解决方案1】:

    像这样:

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

    或:

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

    【讨论】:

    • 还有一点,opencv 在这里有一个很棒的文档docs.opencv.org 你可以在这里找到所有你需要知道的关于 opencv 的信息。
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-18
      • 2011-11-16
      • 2021-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-20
      相关资源
      最近更新 更多