Access usb camera on torizon as a non-root user

Hi Jeremias,

Thanks for your suggestion, which have helped a lot (see at the end of the message which fails or succeed).

But first for completeness of information, the udev rule I added is actually documented by the camera manufacturer, which provides the udev rule and a libNITlibrary.so (+ headers) as a deb 9 package. I had to strip the deb archive to known exactly how to install it on Debian 11 and build some specific versions of the dependencies.

The debian postinst script is as follows :

#!/bin/sh

if [ ! -f /etc/udev/rules.d/88-cyusb.rules ]; then
        echo 'KERNEL=="*", SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", ATTR{idVendor}=="04b4", MODE="0666", GROUP="plugdev", TAG="cyusb_dev"' > /e
tc/udev/rules.d/88-cyusb.rules
fi
udevadm control --reload-rules && udevadm trigger
ln -sf /usr/local/lib/libNITLibrary.so.3.0.1 /usr/local/lib/libNITLibrary.so.3
ln -sf /usr/local/lib/libNITLibrary.so.3.0.1 /usr/local/lib/libNITLibrary.so
echo /usr/local/lib > /etc/ld.so.conf.d/local.conf
/sbin/ldconfig

I did not use udevadm control --reload-rules && udevadm trigger, because it does not seem to be needed (udev seems to detect the camera and trigger the rule, it is just the device access in user space that does not work).

An indeed I added the udev rule at the Dockerfile level (in torizon.buildcommand). in order to store the commands permanently in the philosophy of infrastructure as code, and because I did not dive yet in customizing TorizonCore. This is clearly not the way to go.

So I did try your different suggestions with some failures and successes :

/dev/video* :o:

My camera does not seem to create any /dev/video (/dev/video0, /dev/video1, /dev/video12, /dev/video13 pre-exists), but I did try to add them as --volume /dev/video0:/dev/video0, etc. but that still does not help to detect the camera.

chown :white_check_mark:

Changing the permission of /deb/bus/usb/* to torizon.torizon works but the effect disappears after reboot.

udev rule at container level :o:

I did try :

  • removing MODE="0666" in the udev rule, does not help
  • adding OWNER="torizon", since I guess it should have the same effect as chown but that does not seem to work

udev rule at TorizonCore level :white_check_mark:

Adding the udev rule at the TorizonCore level instead of the container works !

Then the usb device authomatically shows as torizon.plugdev

ls -l /dev/bus/usb/002/002
crw-rw-rw- 1 torizon plugdev 189, 129 Jun  3 09:10 /dev/bus/usb/002/002

So clearly this solution is the way to go. Thanks.

Best regards,
Fabian