Ich bin immer noch nicht gut in Python und verstehe nicht, warum ich manchmal das richtige Bild und manchmal ein beschädigtes graues Bild erhalte.
Ich verwende die Hikvision-API, um den RTSP-Stream abzurufen, und während der Stream funktioniert, sind die Bilder manchmal immer noch vollständig grau.
Hier ist der Code, den ich geschrieben habe:
Code: Select all
import cv2
import time
count = 0
while True:
for x in range(1, 9):
count = count +1
RTSP_URL = f'rtsp://user:password@ip:port/ISAPI/Streaming/Channels/{x}01'
cap = cv2.VideoCapture(RTSP_URL, cv2.CAP_FFMPEG)
result, image = cap.read()
if result:
cv2.imwrite(f"pictures/{x}{count}.png", image)
time.sleep(60)
Mobile version