Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access IP camera with OpenCV

Can't access the video stream. Can any one please help me to get the video stream. I have searched in google for the solution and post another question in stack overflow but unfortunately nothing can't solve the problem.

import cv2
cap = cv2.VideoCapture()
cap.open('http://192.168.4.133:80/videostream.cgi?user=admin&pwd=admin')
while(cap.isOpened()):
    ret, frame = cap.read()
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()
like image 232
Taimur Islam Avatar asked Aug 07 '17 05:08

Taimur Islam


1 Answers

Use code below to access ipcam directly through opencv. Replace the url in VideoCapture with your particular camera rtsp url. The one given generally works for most cameras I've used.

import cv2

cap = cv2.VideoCapture("rtsp://[username]:[pass]@[ip address]/media/video1")

while True:
    ret, image = cap.read()
    cv2.imshow("Test", image)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break
cv2.destroyAllWindows()
like image 92
NumbMonkE Avatar answered Oct 26 '22 06:10

NumbMonkE