Skip to content

Instantly share code, notes, and snippets.

@imneonizer
Created February 27, 2020 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imneonizer/7da5b3965dbaee8a27a9c153d9ce5e6c to your computer and use it in GitHub Desktop.
Save imneonizer/7da5b3965dbaee8a27a9c153d9ce5e6c to your computer and use it in GitHub Desktop.
import cv2
def VideoCapture(uri, width, height, latency):
gst_str = ('rtspsrc location={} latency={} ! '
'rtph264depay ! h264parse ! omxh264dec ! '
'nvvidconv ! '
'video/x-raw, width=(int){}, height=(int){}, '
'format=(string)BGRx ! '
'videoconvert ! appsink').format(uri, latency, width, height)
return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
cap = VideoCapture("rtsp://admin:@192.168.0.178", 1920, 1080, 200)
while True:
success, frame = cap.read()
if not success: break
cv2.imshow("frame", frame)
if cv2.waitKey(1) == ord('q'): break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment