I want to load to opencv an image that I've downloaded. I would like to avoid saving it to a file. I can perfectly download the image:
page_html = requests.get("http://my_web_page.com")
image_src = parse.search('<img id="my_image" src="{}"', page_html.content.decode('utf-8'))[0]
if image_src:
image = requests.get("http://my_web_age.com" + image_src).content
And I can save it to a file and check it with my file explorer:
with open('main_image.png', 'wb') as file:
file.write(image.content)
But if I try to directly load the image from the content of the variable, it doesn't work:
cv2_image = cv2.imread(image.content, cv2.IMREAD_COLOR)
I get:
SystemError: <built-in function imread> returned NULL without setting an error
Reading from the file works nevertheless, but is it possible to skip this step? The data is already in the variable, so it should be possible.