[libcamera-devel] libcamera as non-root

Erik Sohns eriksohns at posteo.net
Wed Dec 30 15:46:56 CET 2020


On 12/30/20 6:45 AM, Sebastian Fricke wrote:
> On 30.12.2020 00:32, Laurent Pinchart wrote:
>> On Tue, Dec 29, 2020 at 08:31:27PM +0000, Kieran Bingham wrote:
>>> On 29/12/2020 18:31, Erik Sohns wrote:
>>> > Hello,
>>> >
>>> > I have a question for the list.
>>> >
>>> > I am trying to integrate libcamera into my Linux application.
>>> > I am making some progress and am enumerating the existing devices 
>>> on my
>>> > system. It turns out, however, that no devices are found when I am 
>>> not
>>> > root. Is there a way around this ? Also, the qcam and cam programs 
>>> only
>>> > seem to work when the user is root.
>>> >
>>> > Any ideas ? Please answer directly, I am not a subscriber of the 
>>> list.
>>>
>>> You'll likely need to add your user account to the 'video' group
>>>
>>>   $ sudo usermod -aG video $USER
>>>   $ newgrp video
>>
>> Most distributions use the video group for V4L2 video device nodes, but
>> some may not put media controller devices in that group. You may want to
>> check ownership of all related devices with
>>
>> ls -l /dev/video* /dev/v4l-* /dev/media*
>>
>> If some of those devices are not in the video group, this should be
>> reported to the distribution.
>>
>>> The newgrp command adds the group to your current session, but you'll
>>> probably just want to log out and back in again completely to make sure
>>> it takes effect.
>>>
>>> Hope this helps, do let us know what you're integrating libcamera 
>>> into -
>>> it's interesting to know where the library gets used.
>
> Can we add this description to the frequently asked questions?
> This seems to be a problem, that can be encountered by multiple new
> users.
> I thought about something like this:
>
> +   Why do I have to be root for devices to be enumerated?
> +
> +   Most distributions use the **video** group for V4L2 video device
> +   nodes. To add yourself to that group use the following:
> +   .. code-block:: bash
> +       :linenos:
> +       sudo usermod -aG video $USER
> +       newgrp video
>
>>
>> -- 
>> Regards,
>>
>> Laurent Pinchart
>
> Greetings,
> Sebastian
>
>> _______________________________________________
>> libcamera-devel mailing list
>> libcamera-devel at lists.libcamera.org
>> https://lists.libcamera.org/listinfo/libcamera-devel

Thanks, that did the trick. However, I needed to restart the machine 
after adding the user to the group for the change to take effect (Fedora 
33), it probably needs to remount the drive.

For the usage: I have a framework called 'ACEStream' (see here: 
http://www.github.com/esohns/ACEStream) that is platform-agnostic and 
can also handle media streams (somewhat related to GStreamer). I will 
write a 'source' plugin wrapping libcamera for it (v4l support is 
already in there) to support an even wider range of (mobile) platforms 
as well.

Greetings,

Erik Sohns



More information about the libcamera-devel mailing list