Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (50.2k points)

I want to access my IP Camera stream, I have used the below code for displaying a standard webcam stream:

import cv2

import numpy as np

cap = cv2.VideoCapture(0)

while(True):

    ret, frame = cap.read()

    cv2.imshow('frame',frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):

        break

cap.release()

cv2.destroyAllWindows()

How can I perform the same exact information but with the IP Camera?

My system:

Python 2.7.14

OpenCV 2.4.9

Teledyne Dalsa Genie Nano XL Camera

You can use video capture Object as

camera = cv2.VideoCapture("IP:PORT/video")

1 Answer

0 votes
by (108k points)

For locating the IP camera in opencv, you need to give the streaming URL of the camera in the constructor of cv2.VideoCapture.

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

rtsp://192.168.1.64/1

It can be initiated with OpenCV like this:

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

You have to give the credentials in the streaming URL as follows:

capture = cv2.VideoCapture('rtsp://username:[email protected]/1')

For more information, kindly refer to the Python certification course. 

Related questions

0 votes
1 answer
asked Mar 21, 2021 in Python by laddulakshana (16.4k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 11, 2020 in Python by ashely (50.2k points)
0 votes
2 answers

Browse Categories

...