问题:cv不能读png
>>> import cv2
>>> cv2.imread("4.jpg")
libpng error: Read Error
解决:
import cv2, random
import os
import numpy as np
from PIL import Image
from PIL import ImageFile
import imghdr
ImageFile.LOAD_TRUNCATED_IMAGES = True
if imghdr.what(name) == "png":
Image.open(name).convert("RGB").save(name)
img = cv2.imread(name)
img = np.array(Image.open(name))