OpenCV转换成PIL.Image格式:
import cv2
from PIL import Image
import numpy
img = cv2.imread("a.jpg")
cv2.imshow("a",img)
image = Image.fromarray(cv2.cvtColor(img,cv2.COLOR_BGR2RGB))
image.show()
cv2.waitKey()
PIL.Image转换成OpenCV格式:
import cv2
from PIL import Image
import numpy
image = Image.open("a.jpg")
image.show()
img = cv2.cvtColor(numpy.asarray(image),cv2.COLOR_RGB2BGR)
cv2.imshow("a", img)
cv2.waitKey()