DEV Community


Posted on


Read an image from an Internet URL in Python3 cv2

By this piece of code we can read image from URL in opencv python3.

Make sure you have installed opencv in system.

pip install opencv-python
Enter fullscreen mode Exit fullscreen mode
import cv2
import urllib.request
import numpy as np

req = urllib.request.urlopen('')
arr = np.asarray(bytearray(, dtype=np.uint8)
img = cv2.imdecode(arr, -1) # 'Load it as it is'

cv2.imshow('random_title', img)
if cv2.waitKey() & 0xff == 27: quit()
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

50 CLI Tools You Can't Live Without

The top 50 must-have CLI tools, including some scripts to help you automate the installation and updating of these tools on various systems/distros.