Libcamera on Raspberry Pi 5

What is the recommended way to work with camera devices that are only supported by libcamera? I have tried using pipewire-libcamera plugin with SDL_CAMERA_DRIVER=pipewire but no luck. Looking to use SDL3 Camera API on Raspberry Pi Camera Module3 on Raspberry Pi5. Any pointers would be appreciated.

I guess I would recommend you verify that PipeWire-libcamera sees your camera hardware and can talk to it, using something that isn’t using SDL. If it can’t, fix that. If it can, make sure SDL3 was built with PipeWire camera support and not just v4l2.

If so, it’s likely an SDL bug and we can dig in further.

I am on Raspberry Pi5 running Pi OS based on Debian Trixie. The camera is a Pi Camera Module 3 as mentioned previously.

Pipewire can see the camera - pw-cli reports it as follows:

        id 85, type PipeWire:Interface:Node/3
                object.serial = "86"
                object.path = "libcamera:/base/axi/pcie@1000120000/rp1/i2c@88000/imx477@1a"
                factory.id = "11"
                client.id = "47"
                device.id = "81"
                priority.session = "850"
                node.description = "imx477"
                node.name = "libcamera_input._base_axi_pcie_1000120000_rp1_i2c_88000_imx477_1a"
                node.nick = "imx477"
                media.class = "Video/Source"
                media.role = "Camera"
        id 86, type PipeWire:Interface:Port/3
                object.serial = "87"
                object.path = "libcamera:/base/axi/pcie@1000120000/rp1/i2c@88000/imx477@1a:capture_0"
                node.id = "85"
                port.id = "0"
                port.name = "capture_1"
                port.direction = "out"
                port.physical = "true"
                port.terminal = "true"
                port.alias = "imx477:capture_1"
                port.group = "stream.0"

I did not mess around with pipewire any further.

Libcamerify exposes the camera as a v4l2 device but looks like SDL cannot recognise the camera with that either, although messages from libcamerify itself indicate the camera being recognised. The output is as below - first just the camera example on its own, then with libcamerify and v4l2 driver (default), and then with pipewire

vilas@picam:~/projects/SDL/build $ ./examples/camera-read-and-draw 
Couldn't find any camera devices! Please connect a camera and try again.

vilas@picam:~/projects/SDL/build $ libcamerify ./examples/camera-read-and-draw 
[0:22:22.376335605] [19206]  INFO Camera camera_manager.cpp:330 libcamera v0.5.2+99-bfd68f78
[0:22:22.394259794] [19209]  INFO RPI pisp.cpp:720 libpisp version 1.3.0
[0:22:22.399405184] [19209]  INFO IPAProxy ipa_proxy.cpp:180 Using tuning file /usr/share/libcamera/ipa/rpi/pisp/imx477.json
[0:22:22.413616002] [19209]  INFO Camera camera_manager.cpp:220 Adding camera '/base/axi/pcie@1000120000/rp1/i2c@88000/imx477@1a' for pipeline handler rpi/pisp
[0:22:22.413683947] [19209]  INFO RPI pisp.cpp:1179 Registered camera /base/axi/pcie@1000120000/rp1/i2c@88000/imx477@1a to CFE device /dev/media0 and ISP device /dev/media2 using PiSP variant BCM2712_C0
Couldn't find any camera devices! Please connect a camera and try again.

vilas@picam:~/projects/SDL/build $ SDL_CAMERA_DRIVER=pipewire ./examples/camera-read-and-draw 
Couldn't find any camera devices! Please connect a camera and try again.


@icculus do you think this is a bug or is it just something not implemented or supported.

Also, happy to sponsor the bug-fix/feature by paying for a raspberry Pi5, camera module 3 and the associated hardware kit if anybody is willing to look at it.

Is it this thing? Amazon.com

I’ll just order one if so; I have a RPi5 here already.

Yes that would be it, although I am surprised by the price. Seems to cost double of what we would have paid in the UK: Raspberry Pi Camera Module 3 - The Pi Hut

Also, note that the MIPI connector on the Pi5 end is 15-way and is 22-way on the camera end. I received an adapter cable with the camera module, but not sure if that is the case with the vendor on Amazon

Thank you Ryan. I didn’t realise who I was talking to here! Thanks for your contributions over the years.

1 Like

Gosh, that is overpriced! I grabbed it off Adafruit instead, including the Pi5 adapter cable.

It’ll be here Wednesday. I’ll report back.

Okay, so here’s the state:

  • The camera works with libcamera on a Pi5 (of course)
  • The camera works with PipeWire (which I confirmed with OBS Studio).
  • The camera does not work with SDL’s PipeWire backend.

There are some obvious issues up front (there are bugs in how we are enumerating camera formats in our PipeWire code), so I’ll try to coerce this to work. I suspect it’s mostly there once I sort those issues out.

Once the bugs are shaken out, there’s no reason to believe this can’t work with SDL’s pipewire backend. Stay tuned!

1 Like

Amazing news. Thanks for your time on this one!

I am not a graphics or imaging expert. But I would love to learn how things work under the hood. Looking forward to seeing what changes were required in the code to support the camera.