I tried many pipelines but none of them can successfully open the VideoCapture object. The following one seems to work with gst-launch-1.0 but not in python (changing xvimagesync to appsink): gst-launch-1.0 v4l2src device=\"/dev/video0\" ! xvimagesink
If working, for capturing from opencv you would use:
cap = cv2.VideoCapture("v4l2src device=/dev/video0 ! video/x-raw, format=YUY2 ! videoconvert ! video/x-raw, format=BGR ! appsink drop=1", cv2.CAP_GSTREAMER)
# Or this one using HW for YUV -> BGRx conversion, so that videoconvert on CPU only removes the 4th byte.
cap = cv2.VideoCapture("v4l2src device=/dev/video0 ! video/x-raw, format=YUY2 ! nvvidconv ! video/x-raw(memory:NVMM) ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink drop=1", cv2.CAP_GSTREAMER)
For reading MJPG format, you may try:
gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg, format=MJPG ! jpegdec ! ximagesink
# Or this one using HW decoder:
gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg, format=MJPG ! nvv4l2decoder mjpeg=1 ! nvvidconv ! xvimagesink