Size of Matrix OpenCV

后端 未结 5 932
遇见更好的自我
遇见更好的自我 2020-12-07 11:36

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, bu

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-07 12:20

    If you are using the Python wrappers, then (assuming your matrix name is mat):

    • mat.shape gives you an array of the type- [height, width, channels]

    • mat.size gives you the size of the array

    Sample Code:

    import cv2
    mat = cv2.imread('sample.png')
    height, width, channel = mat.shape[:3]
    size = mat.size
    

提交回复
热议问题