cv2.imread函数的shape属性,返回的是一个Python Tuple
cv.imread.shape(h, w, 3)
w 对应 x轴,h 对应 y轴,3为通道数
x轴即:宽度,y轴即:高度
3通道图片就是R,G,B,4通道图片就是R,G,B 加上 Alpha 通道,Alpha通道就是透明度通道
其他代码懒得写,都是很基础的,自己看:
import os
import cv2
CurrentPath = os.getcwd()
def read(Path):
for file_name in os.listdir(Path):
img = cv2.imread(Path + "./" + file_name)
if img is not None:
shape = str(img.shape)
print("file name: " + file_name + "\tfile size : " + shape)
else:
print('\n***** Detected other type file:', file_name)
if __name__ == '__main__':
print("current path is ----------- " , CurrentPath)
read(CurrentPath)