Description of Problem:
I have a ModalAI M500 with an Arducam B0205 (link) connected to it. Although the camera shows up with lsusb
, I cannot use it inside my docker container. Other USB cameras work fine. This Arducam camera works fine on my laptop, which runs Linux Mint.
I commonly get the error message that the camera is in use, but lsof
shows it is not used by the container nor any process inside Yocto.
Output of uname -a
and ls /dev | grep video
:
voxl:~$ uname -a
Linux apq8096 3.18.71-perf #1 SMP PREEMPT Sun Jun 6 19:41:01 UTC 2021 aarch64 GNU/Linux
voxl:~$ ls /dev | grep video
video0
video1
video2
video3
video32
video33
video4
The camera is confirmed to be /dev/video2
.
Output of lsof
, lsusb
, ffmpeg
, and related debugging commands:
Commands run on Yocto:
voxl:~$ ./lsof | grep /dev/video2
voxl:~$ lsusb
Bus 001 Device 030: ID 0c45:6369 Microdia
Bus 001 Device 006: ID 1f94:3002
Bus 001 Device 004: ID 0424:7500 Standard Microsystems Corp. LAN7500 Ethernet 10/100/1000 Adapter
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
voxl:~$ ffmpeg -i /dev/video2
ffmpeg version n4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 4.9.3 (GCC)
configuration: --arch=arm --prefix=/builds/voxl-public/voxl-ffmpeg/ipk/data/usr/local --enable-omx
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
[video4linux2,v4l2 @ 0x1761120] Cannot open video device /dev/video2: Device or resource busy
/dev/video2: Device or resource busy
voxl:~$
Yes, I have verified that my lsof
binary works. The camera is the 0c45:6369 Microdia
device listed in lsusb
. Strangely, even though the camera is not in use, ffmpeg
reports "/dev/video2: Device or resource busy
".
Commands run inside my roskinetic container:
roskinetic:~$ v4l2-ctl --device=/dev/video2 -D --list-formats
Failed to open /dev/video2: Device or resource busy
roskinetic:~$ python3
Python 3.9.0 (default, Sep 2 2022, 14:09:47)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cam = cap.open('/dev/video2', cv2.CAP_ANY)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'cap' is not defined
>>> cap = cv2.VideoCapture('/dev/video2', cv2.CAP_ANY)
[ WARN:0@27.752] global /io/opencv/modules/imgcodecs/src/loadsave.cpp (239) findDecoder imread_('/dev/video2'): can't open/read file: check file path/integrity
>>> exit()
roskinetic:~$ ls -al /dev | grep video2
crw-rw----. 1 root video 81, 20 Jan 1 1970 video2
roskinetic:~$ lsof
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
bash 1 root cwd DIR 0,31 4096 31256 /root
bash 1 root rtd DIR 0,31 4096 29395 /
bash 1 root txt REG 179,1 925744 6305171 /bin/bash
bash 1 root mem REG 179,1 39272 1197209 /lib/aarch64-linux-gnu/libnss_files-2.23.so
bash 1 root mem REG 179,1 39312 1197211 /lib/aarch64-linux-gnu/libnss_nis-2.23.so
bash 1 root mem REG 179,1 76632 1197206 /lib/aarch64-linux-gnu/libnsl-2.23.so
bash 1 root mem REG 179,1 31408 1197207 /lib/aarch64-linux-gnu/libnss_compat-2.23.so
bash 1 root mem REG 179,1 1261896 1197197 /lib/aarch64-linux-gnu/libc-2.23.so
bash 1 root mem REG 179,1 10400 1197201 /lib/aarch64-linux-gnu/libdl-2.23.so
bash 1 root mem REG 179,1 154784 6292046 /lib/aarch64-linux-gnu/libtinfo.so.5.9
bash 1 root mem REG 179,1 125776 1197193 /lib/aarch64-linux-gnu/ld-2.23.so
bash 1 root 0u CHR 136,0 0t0 3 /0
bash 1 root 1u CHR 136,0 0t0 3 /0
bash 1 root 2u CHR 136,0 0t0 3 /0
bash 1 root 255u CHR 136,0 0t0 3 /0
lsof 7819 root cwd DIR 0,31 4096 31256 /root
lsof 7819 root rtd DIR 0,31 4096 29395 /
lsof 7819 root txt REG 179,1 171304 7235192 /usr/bin/lsof
lsof 7819 root mem REG 179,1 139560 1197214 /lib/aarch64-linux-gnu/libpthread-2.23.so
lsof 7819 root mem REG 179,1 10400 1197201 /lib/aarch64-linux-gnu/libdl-2.23.so
lsof 7819 root mem REG 179,1 395104 6292022 /lib/aarch64-linux-gnu/libpcre.so.3.13.2
lsof 7819 root mem REG 179,1 1261896 1197197 /lib/aarch64-linux-gnu/libc-2.23.so
lsof 7819 root mem REG 179,1 109656 6292035 /lib/aarch64-linux-gnu/libselinux.so.1
lsof 7819 root mem REG 179,1 125776 1197193 /lib/aarch64-linux-gnu/ld-2.23.so
lsof 7819 root 0u CHR 136,0 0t0 3 /0
lsof 7819 root 1u CHR 136,0 0t0 3 /0
lsof 7819 root 2u CHR 136,0 0t0 3 /0
lsof 7819 root 3r DIR 0,34 0 1 /proc
lsof 7819 root 4r DIR 0,34 0 770582 /proc/7819/fd
lsof 7819 root 5w FIFO 0,9 0t0 770586 pipe
lsof 7819 root 6r FIFO 0,9 0t0 770587 pipe
lsof 7820 root cwd DIR 0,31 4096 31256 /root
lsof 7820 root rtd DIR 0,31 4096 29395 /
lsof 7820 root txt REG 179,1 171304 7235192 /usr/bin/lsof
lsof 7820 root mem REG 179,1 139560 1197214 /lib/aarch64-linux-gnu/libpthread-2.23.so
lsof 7820 root mem REG 179,1 10400 1197201 /lib/aarch64-linux-gnu/libdl-2.23.so
lsof 7820 root mem REG 179,1 395104 6292022 /lib/aarch64-linux-gnu/libpcre.so.3.13.2
lsof 7820 root mem REG 179,1 1261896 1197197 /lib/aarch64-linux-gnu/libc-2.23.so
lsof 7820 root mem REG 179,1 109656 6292035 /lib/aarch64-linux-gnu/libselinux.so.1
lsof 7820 root mem REG 179,1 125776 1197193 /lib/aarch64-linux-gnu/ld-2.23.so
lsof 7820 root 4r FIFO 0,9 0t0 770586 pipe
lsof 7820 root 7w FIFO 0,9 0t0 770587 pipe
roskinetic:~$ ffmpeg -f v4l2 -video_size 720x480 -i /dev/video2 -q:v 16 -r:v 5 -y test.mjpg
ffmpeg version 2.8.17-0ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 5.4.0 (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.12) 20160609
configuration: --prefix=/usr --extra-version=0ubuntu0.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/aarch64-linux-gnu --incdir=/usr/include/aarch64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
libavutil 54. 31.100 / 54. 31.100
libavcodec 56. 60.100 / 56. 60.100
libavformat 56. 40.101 / 56. 40.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 40.101 / 5. 40.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.101 / 1. 2.101
libpostproc 53. 3.100 / 53. 3.100
[video4linux2,v4l2 @ 0x47df00] Cannot open video device /dev/video2: Device or resource busy
/dev/video2: Device or resource busy
roskinetic:~$
Essentially, information inside the container mirrors what I see in Yocto. OpenCV also cannot open the camera. Keep in mind that I can open another (cheaper) USB camera just fine.
Anyone have ideas on why this might be failing?
My application/implementation
I have software set up to analyze the images. This is written in Python, and it is set up to use OpenCV to open /dev/video2
. It worked decently with the previous camera, but I needed a higher quality camera with a better FoV. This camera works great when I test the software on my laptop, but there is some issue with it on the VOXL.
Here is uname from my laptop, if anyone is curious:
Linux forcyte-xenon 5.15.0-71-generic #78~20.04.1-Ubuntu SMP Wed Apr 19 11:26:48 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
I've spent most of today trying to figure this out, I've found some resources online but none of them have really helped. If anyone has ideas on this, it would be greatly appreciated.