'How to convert a hex string to an image vector
I am making an API that reads an image as a hex string. I need to convert the hex string to an image vector like what you would get from: img = cv2.imread('abc.jpg')
I know I can do this by writing hex string to file and read as an image:
import cv2
image_name = 'Test_image.jpg'
with open(image_name, 'wb') as outfile:
outfile.write(hex_string)
img = cv2.imread(image_name)
But my question is how to end up with "img" directly from "hex_string" without needing to write/read from file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|