本文主要在爱芯派 Pro上连接USB摄像头,为下一篇的人体姿势AI识别提供图像。
官方的Debian镜像,也没用去update了,反正也挺新的。
root@maixbox:~# uname -a
Linux maixbox 5.15.73 #1 SMP PREEMPT Wed Aug 16 15:38:30 CST 2023 aarch64 GNU/Linux
嗯,不知道啥时候安装好了。
root@maixbox:~# apt install libjpeg62-turbo-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libjpeg62-turbo-dev is already the newest version (1:2.1.5-2).
libjpeg62-turbo-dev set to manually installed.
The following package was automatically installed and is no longer required:
libutempter0
Use 'apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
root@maixbox:~#
root@maixbox:~# apt install imagemagick
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
libutempter0
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
fonts-droid-fallback fonts-noto-mono fonts-urw-base35 ghostscript gsfonts imagemagick-6-common imagemagick-6.q16 libdjvulibre-text
libdjvulibre21 libfftw3-double3 libgs-common libgs10 libgs10-common libidn12 libijs-0.35 libjbig2dec0 libjxr-tools libjxr0 liblqr-1-0
libmagickcore-6.q16-6 libmagickcore-6.q16-6-extra libmagickwand-6.q16-6 libnetpbm11 libpaper-utils libpaper1 libwmflite-0.2-7 netpbm
Suggested packages:
fonts-noto fonts-freefont-otf | fonts-freefont-ttf fonts-texgyre imagemagick-doc autotrace cups-bsd | lpr | lprng enscript ffmpeg gimp gnuplot
grads graphviz hp2xx html2ps libwmf-bin mplayer povray radiance texlive-base-bin transfig ufraw-batch xdg-utils libfftw3-bin libfftw3-dev
inkscape
The following NEW packages will be installed:
fonts-droid-fallback fonts-noto-mono fonts-urw-base35 ghostscript gsfonts imagemagick imagemagick-6-common imagemagick-6.q16 libdjvulibre-text
libdjvulibre21 libfftw3-double3 libgs-common libgs10 libgs10-common libidn12 libijs-0.35 libjbig2dec0 libjxr-tools libjxr0 liblqr-1-0
libmagickcore-6.q16-6 libmagickcore-6.q16-6-extra libmagickwand-6.q16-6 libnetpbm11 libpaper-utils libpaper1 libwmflite-0.2-7 netpbm
0 upgraded, 28 newly installed, 0 to remove and 2 not upgraded.
Need to get 22.3 MB of archives.
After this operation, 95.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for fontconfig (2.14.1-4) ...
root@maixbox:~# apt install libv4l-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
libutempter0
Use 'apt autoremove' to remove it.
The following additional packages will be installed:
libv4l-0 libv4l2rds0 libv4lconvert0
The following NEW packages will be installed:
libv4l-0 libv4l-dev libv4l2rds0 libv4lconvert0
0 upgraded, 4 newly installed, 0 to remove and 2 not upgraded.
Need to get 437 kB of archives.
After this operation, 1,569 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main arm64 libv4lconvert0 arm64 1.22.1-5+b2 [141 kB]
Get:2 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main arm64 libv4l-0 arm64 1.22.1-5+b2 [107 kB]
Get:3 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main arm64 libv4l2rds0 arm64 1.22.1-5+b2 [80.3 kB]
Get:4 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main arm64 libv4l-dev arm64 1.22.1-5+b2 [108 kB]
Fetched 437 kB in 0s (881 kB/s)
Selecting previously unselected package libv4lconvert0:arm64.
(Reading database ... 69178 files and directories currently installed.)
Preparing to unpack .../libv4lconvert0_1.22.1-5+b2_arm64.deb ...
Unpacking libv4lconvert0:arm64 (1.22.1-5+b2) ...
Selecting previously unselected package libv4l-0:arm64.
Preparing to unpack .../libv4l-0_1.22.1-5+b2_arm64.deb ...
Unpacking libv4l-0:arm64 (1.22.1-5+b2) ...
Selecting previously unselected package libv4l2rds0:arm64.
Preparing to unpack .../libv4l2rds0_1.22.1-5+b2_arm64.deb ...
Unpacking libv4l2rds0:arm64 (1.22.1-5+b2) ...
Selecting previously unselected package libv4l-dev:arm64.
Preparing to unpack .../libv4l-dev_1.22.1-5+b2_arm64.deb ...
Unpacking libv4l-dev:arm64 (1.22.1-5+b2) ...
Setting up libv4lconvert0:arm64 (1.22.1-5+b2) ...
Setting up libv4l2rds0:arm64 (1.22.1-5+b2) ...
Setting up libv4l-0:arm64 (1.22.1-5+b2) ...
Setting up libv4l-dev:arm64 (1.22.1-5+b2) ...
Processing triggers for libc-bin (2.36-9+deb12u3) ...
ldconfig: /usr/local/lib/libdrm.so.2 is not a symbolic link
主要是apt install build-essential
,貌似之前编译demo的时候已经安装好了,没有装的话执行下。
root@maixbox:~# apt install build-essential
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
build-essential is already the newest version (12.9).
The following package was automatically installed and is no longer required:
libutempter0
Use 'apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
可以检查下:
root@maixbox:~# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/12/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 12.2.0-14' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-12 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.2.0 (Debian 12.2.0-14)
AX650N
处理能力毋庸置疑,直接板子上编译和安装,源代码直接从github上拉取。
root@maixbox:~# git clone https://github.com/jacksonliam/mjpg-streamer.git
Cloning into 'mjpg-streamer'...
remote: Enumerating objects: 2964, done.
remote: Total 2964 (delta 0), reused 0 (delta 0), pack-reused 2964
Receiving objects: 100% (2964/2964), 3.48 MiB | 4.25 MiB/s, done.
Resolving deltas: 100% (1885/1885), done.
root@maixbox:~#
进入/mjpg-streamer/mjpg-streamer-experimental 文件夹,执行 make all。
速度非常快,说明SoC很给力。看看编译后生成的文件:
然后make install
,秒完成:
首先确保网络正常连接。
之后插入USB camera,查看dmesg log已经识别:
通过对比video大法判断设备名,找出是/dev/video0:
root@maixbox:~/mjpg-streamer/mjpg-streamer-experimental# ls -l /dev/video*
crw-rw---- 1 root video 81, 0 Jan 15 21:09 /dev/video0
crw-rw---- 1 root video 81, 1 Jan 15 21:09 /dev/video1
直接输入 mjpg_streamer 即可启动服务,默认的是video0,爱芯派 Pro 开发板的USB摄像头是video0。在启动服务命令中通过“-d /dev/video0” 选项来指定,或者直接默认./mjpg_streamer -i "./input_uvc.so -f 30 -q 90 -n" -o "./output_http.so -w ./www"
。
y是表示YUV格式。如果没有-y,默认启动是mjpeg格式
-d指定设备
-f 制订帧数,默认30帧
-r指定视频大小,如320×240
-q指定画质,默认80对于输出参数:
-p 指定端口,一般是8080
-w 指定网页目录,设置的是/www目录
-c设置通过密码访问
启动后的日志如下:
打开浏览器,访问URL为:[爱芯派 Pro 开发板IP]:8080 ,得到的内容如下:
取一张图的URL为`IP:8080?action=snapshot,直接给自己照相:
更多回帖