libcamerasrc and formats?

Nicolas Dufresne nicolas at ndufresne.ca
Wed Mar 15 18:13:43 UTC 2023


Hi,

Le mercredi 15 mars 2023 à 17:24 +0100, Florian Echtler via gstreamer-devel a
écrit :
> Hello everyone,
> 
> I'm experimenting with a Raspberry Pi camera and would like to process the 
> frames with OpenCV. Apparently, the "modern" way of doing so is through 
> libcamera, and for OpenCV, this means using a GStreamer pipeline with libcamerasrc.
> 
> For efficiency reasons, I'd like to get a grayscale image directly from the 
> camera to avoid unneeded conversions; so I used the following pipeline:
> 
> libcamerasrc ! 
> video/x-raw,width=(int)640,height=(int)480,framerate=(fraction)30/1,format=GRAY 
> ! appsink
> 
> "GRAY" is listed as a supported format for the camera in the Video4Linux device, 
> but I don't get a working pipeline when I try that. If I leave out the format 
> parameter, then I'm getting NV12 (or I can pick something generic like RGB). How 
> can I see which formats I can actually get out of libcamerasrc and the sensor?

Any chance you can give this patch a try ? I'll post it to the libcamera project
if you can confirm its working. Note that libcamerasrc is entirely developed as
part of libcamera project.

---
commit abf017f5c0f547ceaa863e658f22af9f547a863d (HEAD -> logger-crash)
Author: Nicolas Dufresne <nicolas.dufresne at collabora.com>
Date:   Wed Mar 15 14:10:08 2023 -0400

    gstreamer: Map R8 pixel format
    
    This enables monochrome 8bit to be supported in libcamerasrc.
    
    Signed-off-by: Nicolas Dufresne <nicolas.dufresne at collabora.com>

diff --git a/src/gstreamer/gstlibcamera-utils.cpp b/src/gstreamer/gstlibcamera-
utils.cpp
index 750ec351..f1e34b60 100644
--- a/src/gstreamer/gstlibcamera-utils.cpp
+++ b/src/gstreamer/gstlibcamera-utils.cpp
@@ -26,6 +26,9 @@ static struct {
        { GST_VIDEO_FORMAT_ENCODED, formats::SGRBG8 },
        { GST_VIDEO_FORMAT_ENCODED, formats::SRGGB8 },
 
+       /* Monochrome */
+       { GST_VIDEO_FORMAT_GRAY8, formats::R8 },
+
        /* RGB16 */
        { GST_VIDEO_FORMAT_RGB16, formats::RGB565 },
 





More information about the gstreamer-devel mailing list