Last active
December 27, 2019 15:33
[OpenCV] Streaming video from IP camera
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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