forked from hasmithagunda123/ALL_INDIA_HACKATHON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtsp.py
41 lines (24 loc) · 722 Bytes
/
rtsp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import cv2
import argparse
parser = argparse.ArgumentParser("-r", "--rtsp", "rtsp streaming url")
args = parser.parse_args()
cap = cv2.VideoCapture(args.rtsp)
while(cap.isOpened):
suc,frame= cap.open()
if not suc:
print("Ending the frame as no more frames are available")
break
## Further Code Goes Here
import cv2
rtsp_url = "rtsp://username:password@ip_address:554/path"
cap = cv2.VideoCapture(rtsp_url)
while True:
ret, frame = cap.read()
if not ret:
print("Error reading frame from RTSP stream")
break
cv2.imshow("RTSP Stream", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()