Access IP Camera in Python OpenCV

后端 未结 11 1411
执笔经年
执笔经年 2020-11-29 01:49

How do I access my IP Camera stream?

Code for displaying a standard webcam stream is

import cv2
import numpy as np

cap = cv2.VideoCapture(0)

while(Tr         


        
11条回答
  •  眼角桃花
    2020-11-29 02:32

    This works with my IP camera:

    import cv2
    
    #print("Before URL")
    cap = cv2.VideoCapture('rtsp://admin:123456@192.168.1.216/H264?ch=1&subtype=0')
    #print("After URL")
    
    while True:
    
        #print('About to start the Read command')
        ret, frame = cap.read()
        #print('About to show frame of Video.')
        cv2.imshow("Capturing",frame)
        #print('Running..')
    
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break
    
    cap.release()
    cv2.destroyAllWindows()
    

    I found the Stream URL in the Camera's Setup screen:

    Note that I added the Username (admin) and Password (123456) of the camera and ended it with an @ symbol before the IP address in the URL (admin:123456@)

提交回复
热议问题