Last active
November 25, 2019 02:54
-
-
Save addisaden/b5d44b5c06172733d9edda4bcf9326b2 to your computer and use it in GitHub Desktop.
get an unbreakable (well everything is breakable) streaminput in opencv python. this could be a replacement for the rtsp streaming which are really fragile if used in VideoCapture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python3 | |
#-*- encoding: utf-8 -*- | |
import cv2 | |
import numpy as np | |
# start this: | |
# ffmpeg -i /dev/video0 -f mpegts udp://localhost:1337 | |
# ffmpeg -i rtsp://... -f mpegts udp://localhost:1337 | |
cameraCapture = cv2.VideoCapture('udp://localhost:1337') | |
cv2.namedWindow('MyWindow') | |
print('Showing camera feed. Click window or press any key to stop.') | |
while True: | |
success, frame = cameraCapture.read() | |
cv2.imshow('MyWindow', frame) | |
if cv2.waitKey(1) & 0xff == ord("q"): | |
break | |
cv2.destroyWindow('MyWindow') | |
cameraCapture.release() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!