Usually I would create an image in OpenCV as:
from cv2 import imread
img = imread("/home/nick/myfile.jpg")
But already have the contents of the file in another variable, so how to I create an OpenCV from this directly? eg
fc = open("/home/nick/myfile.jpg", "rb").read()
img = something(fc)
What is something
? Is there an OpenCV or numpy function to do this?
cv2.imdecode() can do that in memory. and yes, it wants a numpy array as input
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.