07-15-2023, 06:42 AM
(07-14-2023, 08:59 PM)Kevin Kofler Wrote: So you are using OpenCV. It looks like your OpenCV is trying to use raw legacy V4L2 (or even V4L1) as the backend. That will not work. Since OpenCV does not (currently) support libcamera directly (nor Pipewire), you will need an OpenCV compiled with GStreamer support, which should work with libcamera if OpenCV is using GStreamer correctly. (Unfortunately, GStreamer exposes the implementation details in some APIs, so some applications using GStreamer do not work unchanged with libcamera.)
EDIT: Judging from the errors you quoted in another thread, it looks like OpenCV is already using GStreamer, but in a way that hardcodes the V4L2 source (v4l2src0), so the OpenCV GStreamer backend needs fixing.
Thanks.
I did some quick research and I found the identifiers for the backends
Code:
>>> [ (b,cv2.videoio_registry.getBackendName(b)) for b in cv2.videoio_registry.getCameraBackends() ]
[(1800, 'GSTREAMER'), (200, 'V4L2'), (300, 'FIREWIRE'), (2500, 'UEYE'), (1700, 'GPHOTO2')]
>>> assert cv2.CAP_GSTREAMER == 1800
>>> cv2.videoio_registry.getBackendName(cv2.CAP_GSTREAMER)
'GSTREAMER'
But OpenCV stills calls v4l when I call `VideoCapture`
Code:
>>> cap = cv2.VideoCapture(0,cv2.CAP_GSTREAMER)
[ WARN:0@1615.039] global ./modules/videoio/src/cap_gstreamer.cpp (2401) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src9 reported: Device '/dev/video0' is not a capture device.
[ WARN:0@1615.040] global ./modules/videoio/src/cap_gstreamer.cpp (1356) open OpenCV | GStreamer warning: unable to start pipeline
[ WARN:0@1615.040] global ./modules/videoio/src/cap_gstreamer.cpp (862) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created