Lib[rem5|camera] to use everywhere

Checklist to share L5 cameras between apps:

Note: I believe that you use the latest version of Byzantium or Crimson backports.

0. Required packages should be installed

$ sudo apt install pipewire-libcamera libcamera-tools gstreamer1.0-pipewire gstreamer1.0-tools

1. Cameras should be visible by the lib:

$ cam -l
[0:21:55.572391385] [3744]  INFO Camera camera_manager.cpp:327 libcamera v0.4.0
...
Available cameras:
1: Internal front camera (/base/soc@0/bus@30800000/i2c@30a40000/camera@20)
2: Internal back camera (/base/soc@0/bus@30800000/i2c@30a50000/camera@2d)

2. The library should be able to capture an image:

$ cam -c1 -C1
...
cam0: Capture 1 frames
1429.065381 (0.00 fps) cam0-stream0 seq: 000000 bytesused: 7970688

3. At this stage you should be able to grab video stream e.g. using gstreamer:

$ gst-launch-1.0 libcamerasrc camera-name="/base/soc@0/bus@30800000/i2c@30a40000/camera@20" saturation=5 ! video/x-raw,format=RGB,width=720, height=576,framerate=10/1 ! videoconvert ! queue ! fpsdisplaysink text-overlay=false

4. Wireplumber should see your cameras:

(check README, section No Sound first)

$ wpctl satus
PipeWire 'pipewire-0' [1.4.1, purism@pureos, cookie:3974875000]
 └─ Clients:
        33. WirePlumber (video-only)            [1.4.1, purism@pureos, pid:1235]
        41. WirePlumber (video-only) [export]   [1.4.1, purism@pureos, pid:1235]
        56. xdg-desktop-portal                  [1.4.1, purism@pureos, pid:1500]
        57. xdg-desktop-portal-wlr              [1.4.1, purism@pureos, pid:2056]
        58. chatty                              [1.4.1, purism@pureos, pid:1878]
        59. wpctl 

Video
 ├─ Devices:
 │      42. imx-capture                         [v4l2]
 │      43. imx-capture                         [v4l2]
 │      44. nxp,imx8mq-vpu-g1-dec               [v4l2]
 │      45. nxp,imx8mq-vpu-g2-dec               [v4l2]
 │      46. hi846                               [libcamera]
 │      47. s5k3l6xx                            [libcamera]
 │  
 └─ Sources:
    *   52. Internal front camera
        54. Internal back camera

5. Grabbing used pipewire source also should work

path option is important, it must be equal your source id

$ gst-launch-1.0 pipewiresrc path=52 ! videoconvert ! video/x-raw,format=RGB,framerate=10/1 ! fpsdisplaysink text-overlay=false

6. Enjoy your cameras!

In fact - not. Just because a lot of options have not been realized yet (like autofocus) inside libcamera or realized not optimal.

6 Likes