Skip to content

Instantly share code, notes, and snippets.

@johnnylord
Last active April 20, 2022 07:26
Show Gist options
  • Save johnnylord/b5f003e62c1f4eb9c6e2ae9567c4f3d0 to your computer and use it in GitHub Desktop.
Save johnnylord/b5f003e62c1f4eb9c6e2ae9567c4f3d0 to your computer and use it in GitHub Desktop.
import time
import cv2
pipeline = (
"nvarguscamerasrc ! "
"video/x-raw(memory:NVMM), "
"width=(int)1920, height=(int)1080, "
"format=(string)NV12, framerate=(fraction)30/1 ! "
"queue ! "
"nvvidconv ! "
"video/x-raw, "
"width=(int)1920, height=(int)1080, "
"format=(string)BGRx, framerate=(fraction)30/1 ! "
"videoconvert ! "
"video/x-raw, format=(string)BGR ! "
"appsink"
)
cap = cv2.VideoCapture(pipeline, cv2.CAP_GSTREAMER)
try:
while True:
ret, frame = cap.read()
if not ret:
break
print(time.strftime('%X'), frame.shape)
except KeyboardInterrupt as e:
cap.release()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment