Access IP Camera in Python OpenCV

后端 未结 11 1432
执笔经年
执笔经年 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:37

    You can access most IP cameras using the method below.

    import cv2 
    
    # insert the HTTP(S)/RSTP feed from the camera
    url = "http://username:password@your_ip:your_port/tmpfs/auto.jpg"
    
    # open the feed
    cap = cv2.VideoCapture(url)
    
    while True:
        # read next frame
         ret, frame = cap.read()
        
        # show frame to user
         cv2.imshow('frame', frame)
        
        # if user presses q quit program
         if cv2.waitKey(1) & 0xFF == ord("q"):
            break
    
    # close the connection and close all windows
    cap.release()
    cv2.destroyAllWindows()
    

提交回复
热议问题