Thursday, June 28, 2018

OpenCV V4l2 using Gstreamer

OpenCV V4l2 using Gstreamer

resize window

12cv2.namedWindow("visiondemo",cv2.WINDOW_FULLSCREEN)
cv2.resizeWindow('visiondemo', 1920,1080)

set fps

123cap.set(cv2.CAP_PROP_FRAME_WIDTH,1920)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT,1080)
cap.set(cv2.CAP_PROP_FPS,30)

Setup Video

Normal Setup

1cap = cv2.VideoCapture("v4l2src device=/dev/video0 ! appsink")

JPEG Setup

1cap = cv2.VideoCapture("v4l2src device=/dev/video0 do-timestamp=true ! image/jpeg, width=1920, height=1080, framerate=30/1 ! jpegdec ! videoconvert ! appsink")

TEE Setup

1cap = cv2.VideoCapture("v4l2src device=/dev/video0 do-timestamp=true ! image/jpeg, width=1920, height=1080, framerate=30/1 ! jpegdec ! tee name=t ! queue ! videoconvert ! appsink t. ! queue ! videoconvert ! videoscale ! videorate ! video/x-raw,width=640,height=480,framerate=15/1 ! v4l2sink device=/dev/video2")

Play Video

123456789101112cap = cv2.VideoCapture("v4l2src device=/dev/video0 ! appsink")

while True:
  ret, image = cap.read()
  if ret == True:
    print("capture not working")
    break
    
  key = cv2.waitKey(1)
  if (key & 0xFF) == ord('q'):
    break
    

No comments:

Post a Comment