def str2img(jpgstr, orientation=None):
import numpy as np
import cv2
arr = np.fromstring(jpgstr, np.uint8)
img = cv2.imdecode(arr, cv2.IMREAD_COLOR)
if orientation == 1:
return cv2.flip(cv2.transpose(img), 0) # counter-clockwise
if orientation == 3:
return cv2.flip(cv2.transpose(img), 1) # clockwise
return img
评论列表
文章目录