I’m attempting to create a gstreamer pipeline using OpenCV to simply open and retrieve raw data from a Y16 uvc webcam. Looking at the output from a gst-launch-1.0 command, it appears as if the GRAY16_LE pixel format is supported, and the one I want. Output from the command:
~/Documents/dev$ gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw,format='GRAY16_LE' ! fakesink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
However, when I go to implement the pipeline and get data out in OpenCV, either C++ or python, I’m unable to get 16-bit data.
cap = cv2.VideoCapture("v4l2src ! videoconvert ! video/x-raw,format=GRAY16_LE! appsink",
cv2.CAP_GSTREAMER)
ret, gray = cap.read()
print(gray[0,0])
cv2.imshow('frame', gray)
Command line errors:
~/Documents/dev$ python3 cam.py
[ WARN:0] global /home/opencv-4.1.1/modules/videoio/src/cap_gstreamer.cpp (1757) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Internal data stream error.
[ WARN:0] global /home/opencv-4.1.1/modules/videoio/src/cap_gstreamer.cpp (886) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0] global /home/opencv-4.1.1/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Traceback (most recent call last):
File "cam.py", line 13, in <module>
cv2.imshow('frame', gray)
cv2.error: OpenCV(4.1.1) /home/opencv-4.1.1/modules/highgui/src/window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
When I change the format to GRAY8, it seems to grab 8 bit data fine with the following warning:
~/Documents/dev$ python3 cam.py
[ WARN:0] global /home/opencv-4.1.1/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
Gtk-Message: 12:52:51.939: Failed to load module "canberra-gtk-module"
What’s the proper method to grab Y16 data?