image.py 312 B

1234567891011
  1. from base64 import b64decode
  2. import numpy as np
  3. import cv2
  4. def base64_to_np(img_data):
  5. color_image_flag = 1
  6. img_data = img_data.split(',',1)[-1]
  7. img = cv2.imdecode(np.fromstring(b64decode(img_data), dtype=np.uint8), color_image_flag)
  8. # img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
  9. return img