반응형
import os
import cv2
from pathlib import Path
from datetime import datetime
path = Path('/home/ubuntu/data/')
path.mkdir(parents=True, exist_ok=True)
src = '/dev/video0'
W, H, fps = 1920, 1080, 6
cap = cv2.VideoCapture(src)
fourcc = cv2.VideoWriter_fourcc('H','2','6','4')
cap.set(3, W)
cap.set(4, H)
cap.set(5, fps)
cap.set(6, fourcc)
t = datetime.now().strftime('%Y-%m-%d_%H-%M-%S_%f')
f_name = os.path.join(path, t)
out = cv2.VideoWriter(f_name+'.avi', fourcc, fps, (W,H))
while(True):
ret, frame = cap.read()
if ret:
out.write(frame)
cv2.imshow('frame', cv2.resize(frame, dsize=(860, 540)))
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
cap.release()
out.release()
cv2.destroyAllWindows()
Set video format in jetson
ENV : Jetson AGX Xavier with JetPack 4.5.1 (Ubuntu 18.04)
$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format=YUY2,width=1920,height=1080,framerate=6/1 ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12' ! nvoverlaysink
https://jstar0525.tistory.com/102
반응형