Like here How to download image using requests , but to memory, using http://docs.python-requests.org.
You can use the following code, the image data will be set in img
, not a file in the disk, than you can manipulate it with opencv.
import io
import requests
from PIL import Image
import matplotlib.pyplot as plt
url = 'http://example.com/img.jpg'
data = requests.get(url).content
img = Image.open(io.BytesIO(data))
plt.imshow(img)
plt.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With