OpenCV-Python无法直接读取gif格式的图片,可用PIL读取后转换为bmp格式或者其他格式(jpg,png)
import osimport cv2 as cvfrom PIL import Imagemask_p='1st_manual'for f in os.listdir(mask_p):print(f)mask=os.path.join(mask_p,f)print(mask)# img=cv.imread(os.path.join(p,f),0)img=Image.open(mask)print(img)# cv.imwrite('\\label\\'+f.strip('gif')+'bmp',img)img.save('.\\label\\'+f.strip('gif')+'bmp')