PIL库与OpenCV库读取图片的区别

用PIL库(Pillow:【pip install pillow】)读取图片:

from PIL import Image

img = Image.open(img_path)
size = img.size
w = img.size[0]
h = img.size[1]

用OpenCV库读取图片:

import cv2

img = cv2.imread(img_path)
size = img.size
w = img.size[1]
h = img.size[0]

区别在于:两者的w和h的位置是不同的!!

你可能感兴趣的:(#,Python,#,OpenCV,opencv,计算机视觉,python)