矩阵OpenCV的大小 [英] Size of Matrix 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屋!