opencvopencv-mat

Size of Matrix 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.

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


Solution

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