Access IP Camera in Python OpenCV

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

    An IP camera can be accessed in opencv by providing the streaming URL of the camera in the constructor of cv2.VideoCapture.

    Usually, RTSP or HTTP protocol is used by the camera to stream video. An example of IP camera streaming URL is as follows:

    rtsp://192.168.1.64/1

    It can be opened with OpenCV like this:

    capture = cv2.VideoCapture('rtsp://192.168.1.64/1')
    

    Most of the IP cameras have a username and password to access the video. In such case, the credentials have to be provided in the streaming URL as follows:

    capture = cv2.VideoCapture('rtsp://username:password@192.168.1.64/1')
    

提交回复
热议问题