Skip to content

Instantly share code, notes, and snippets.

@raiever
Last active December 27, 2019 15:33
Show Gist options
  • Save raiever/3f2a63c8a5bf9ce836c76332d37f3789 to your computer and use it in GitHub Desktop.
Save raiever/3f2a63c8a5bf9ce836c76332d37f3789 to your computer and use it in GitHub Desktop.
[OpenCV] Streaming video from IP camera
# opencv-python: 4.1.1.26
# python: 3.7.3
import cv2
source = 'rtsp://admin:password@192.168.2.196/profile2/media.smp'
cap = cv2.VideoCapture(source)
if cap.isOpened():
cv2.namedWindow("ip camera demo", cv2.WINDOW_AUTOSIZE)
while True:
ret_val, frame = cap.read()
frame = cv2.resize(frame, (640,360))
cv2.imshow("ip camera demo", frame)
cv2.waitKey(10)
else:
print('camera open failed')
cap.release()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment