import os
import cv2
import numpy as np
path = "/raid/data/jianhuang_test/jpg"
imgList = os.listdir(path)
for i in imgList:
imgPath = os.path.join(path, i)
if os.path.getsize(imgPath) == 0:
os.remove(imgPath)
continue
image = cv2.imdecode(np.fromfile(imgPath, dtype=np.uint8), -1)
try:
image.shape
except:
os.remove(imgPath)
opencv清除文件夹中空图片或损坏图片
最新推荐文章于 2022-08-04 17:07:32 发布