矩阵OpenCV的大小 [英] Size of Matrix OpenCV

查看:161
本文介绍了矩阵OpenCV的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这可能非常初级,但是我是OpenCV的新手.您能否告诉我如何在OpenCV中获取矩阵的大小?我用谷歌搜索,并且仍在搜索,但是如果您知道答案,请帮助我.

I know this might be very rudimentary, but I am new to OpenCV. Could you please tell me how to obtain the size of a matrix in OpenCV?. I googled and I am still searching, but if any of you know the answer, please help me.

大小以行和列数为单位.

Size as in number of rows and columns.

有没有办法直接获得2D矩阵的最大值?

And is there a way to directly obtain the maximum value of a 2D matrix?

推荐答案

cv:Mat mat;
int rows = mat.rows;
int cols = mat.cols;

cv::Size s = mat.size();
rows = s.height;
cols = s.width;

还要注意步幅> = cols;这意味着该行的实际大小可以大于元素大小x cols.这与连续Mat的问题不同,并且与数据对齐有关.

Also note that stride >= cols; this means that actual size of the row can be greater than element size x cols. This is different from the issue of continuous Mat and is related to data alignment.

这篇关于矩阵OpenCV的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆