-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrtsp.py
More file actions
35 lines (25 loc) · 891 Bytes
/
rtsp.py
File metadata and controls
35 lines (25 loc) · 891 Bytes
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
import cv2
import threading
# Inicializa el objeto VideoCapture con la cámara web por defecto
cap = cv2.VideoCapture(0)
# Configura el ancho y alto del frame a transmitir
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
# Inicializa el codec y crea el objeto VideoWriter
fourcc = cv2.VideoWriter_fourcc(*'MjPG')
out = cv2.VideoWriter('http://localhost:8080/live/stream', fourcc, 20.0, (640, 480)) #cambie el rtsp por el http
while True:
# Lee el siguiente frame de la cámara
ret, frame = cap.read()
if not ret:
break
# Escribir el frame a la salida
out.write(frame)
# Mostrar el frame en una ventana
cv2.imshow('Live Stream', frame)
if cv2.waitKey(1) == ord('q'):
break
# Liberar la cámara y cerrar las ventanas
cap.release()
out.release()
cv2.destroyAllWindows()