ホストで Ubuntu 18.04 を実行し、LXC コンテナー内で Ubuntu 20.04 を実行しています。私の目標は、LXC コンテナー内で ROS2 (Ubuntu 20.04 が必要) を実行し、それを使用して 2 つの dynamixel サーボ モーターと USB Logitech Web カメラに接続することです。OpenCV と dlib をインストールできるように、コンテナー内に miniconda もインストールしました。コンテナ内で conda 仮想環境も使用しています。
上記のソフトウェアはすべて正常に動作します。ここで、OpenCV を使用して Web カメラにアクセスする必要があります。このコマンドをテストに使用します。
python -c "import cv2;print(cv2.VideoCapture(0).isOpened())"
True
ホストに戻りますが、戻ります
[ WARN:0] global ../modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video0): can't open camera by index
False
コンテナの中から。
これまでのところ、私は試しました:
lxc config device add rosfoxy video0 unix-char path=/dev/video0
でvideo0
、それでも同じエラーが発生しますvideo1
。video2
lxc config device add rosfoxy logitech usb vendorid=046d productid=082b
が発生しましたDevice logitech added to rosfoxy
が、それでも同じエラーが発生しました。lxc profile device add ros logitech usb vendorid=046d productid=082b
次に、どちらが結果になる かを試しましたDevice logitech added to ros
。テストすると、同じエラーが発生します。glxgears
両方とglxinfo
ホストでテストされ、両方とも正常に動作します。ただし、LXC コンテナ内からテストすると問題なく動作しますが、最初に次のエラーが発生します。
libGL error: MESA-LOADER: failed to retrieve device information
libGL error: Version 4 or later of flush extension not found
libGL error: failed to load driver: i915
libGL error: failed to open /dev/dri/card0: No such file or directory
libGL error: failed to load driver: i965
3073 frames in 5.0 seconds = 614.256 FPS
5238 frames in 5.0 seconds = 1047.546 FPS
3766 frames in 5.0 seconds = 753.186 FPS
4214 frames in 5.0 seconds = 842.731 FPS
4926 frames in 5.0 seconds = 985.092 FPS
6007 frames in 5.0 seconds = 1201.399 FPS
5694 frames in 5.0 seconds = 1138.660 FPS
guvcview
ホストでテストされ、正常に動作します。しかし、コンテナでは機能しません。次のようになります。
V4L2_CORE: ERROR opening V4L2 interface for /dev/video2
V4L2_CORE: ERROR opening V4L2 interface for /dev/video3
V4L2_CORE: ERROR opening V4L2 interface for /dev/video0
V4L2_CORE: ERROR opening V4L2 interface for /dev/video1
GUVCVIEW: version 2.0.6
GUVCVIEW: couldn't open /home/ubuntu//.config/guvcview2/video0 for read: No such file or directory
V4L2_CORE: ERROR opening V4L interface: Permission denied
GUVCVIEW (1): Guvcview error
no video device found
(guvcview:1526): dbind-WARNING **: 19:29:55.201: Couldn't connect to accessibility bus: Failed to connect to socket /tmp/dbus-EhmzLUeJ8h: Connection refused
(guvcview:1526): Gtk-WARNING **: 19:29:55.307: Theme parsing error: <data>:1:17: not a number
(guvcview:1526): Gtk-WARNING **: 19:29:55.307: Theme parsing error: <data>:1:31: Using Pango syntax for the font: style property is deprecated; please use CSS syntax
(guvcview:1526): Gtk-WARNING **: 19:29:55.307: Theme parsing error: <data>:1:17: not a number
(guvcview:1526): Gtk-WARNING **: 19:29:55.307: Theme parsing error: <data>:1:32: Using Pango syntax for the font: style property is deprecated; please use CSS syntax
何をすべきかアドバイスしていただけますか?
更新 1:
試してみlxc config device add rosfoxy video0 unix-char path=/dev/video0 gid=1000
ましたが、うまくいかないようです。
コンテナの中から私は彼らが試しました
(base) ubuntu@rosfoxy:~$ v4l2-ctl --all
Failed to open /dev/video0: Permission denied
しかし、追加するsudo
と次のようになりました。
(base) ubuntu@rosfoxy:~$ sudo v4l2-ctl --all
Driver Info:
Driver name : uvcvideo
Card type : Webcam C170: Webcam C170
Bus info : usb-0000:00:14.0-1
Driver version : 5.4.86
Capabilities : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
...
ウェブカメラが検出されたようです!
しかし、私はまだ得る
(py38) ubuntu@rosfoxy:~$ python -c "import cv2;print(cv2.VideoCapture(0).isOpened())"
[ WARN:0] global ../modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video0): can't open camera by index
False
更新 2:
lxc config device remove rosfoxy video0
最初に発行するべきだったlxc config device add rosfoxy video0 unix-char path=/dev/video0 gid=1000
Simos に感謝https://discuss.linuxcontainers.org/t/cant-open-camera-by-index-on-lxc-container/10452/8