Python OpenCV load image from byte string
This is what I normally use to convert images stored in database to OpenCV images in Python. import numpy as np import cv2 from cv2 import cv # Load image as string from file/database fd = open(‘foo.jpg’) img_str = fd.read() fd.close() # CV2 nparr = np.fromstring(img_str, np.uint8) img_np = cv2.imdecode(nparr, cv2.CV_LOAD_IMAGE_COLOR) # cv2.IMREAD_COLOR in OpenCV … Read more