这篇来测试下USB摄像头。
一、USB摄像头设备
1.1、查看USB摄像头模块
USB摄像头连接到开发板后,执行命令:lsmod来查看内核加载的USB摄像头硬件设备
1.2、查看摄像头设备节点
更新软件包
安装v4l-utils
biqu@BTT-CB1:~$ sudo apt install -y v4l-utils
查看设备节点
biqu@BTT-CB1:~$ v4l2-ctl --list-device
二、fswebcam摄像头拍照
2.1、安装fswebcamm
biqu@BTT-CB1:~$ sudo apt-get install -y fswebcam
2.2、执行拍照
biqu@BTT-CB1:/home$ sudo fswebcam -d /dev/video0 --no-banner -r 640x480 -S 5 ./p1.jpg
生成的图片
复制到电脑,打开图片
二、motion测试USB摄像头
2.1、安装motion软件
biqu@BTT-CB1:~$ sudo apt install -y motion
biqu@BTT-CB1:~$ sudo apt install -y motion
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
libmariadb3 libmicrohttpd12 libpq5 mariadb-common mysql-common
Suggested packages:
default-mysql-client postgresql-client
The following NEW packages will be installed:
libmariadb3 libmicrohttpd12 libpq5 mariadb-common motion mysql-common
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 984 kB of archives.
After this operation, 3,868 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian bullseye/main arm64 mysql-common all 5.8+1.0.7 [7,464 B]
Get:2 http://deb.debian.org/debian bullseye/main arm64 mariadb-common all 1:10.5.19-0+deb11u2 [37.0 kB]
Get:3 http://deb.debian.org/debian bullseye/main arm64 libmariadb3 arm64 1:10.5.19-0+deb11u2 [167 kB]
Get:4 http://deb.debian.org/debian bullseye/main arm64 libmicrohttpd12 arm64 0.9.72-2 [104 kB]
Get:5 http://deb.debian.org/debian-security bullseye-security/main arm64 libpq5 arm64 13.11-0+deb11u1 [174 kB]
Get:6 http://deb.debian.org/debian bullseye/main arm64 motion arm64 4.3.2-1 [495 kB]
Fetched 984 kB in 18s (54.8 kB/s)
Preconfiguring packages ...
dpkg: warning: parsing file '/var/lib/dpkg/status' near line 15780 package 'linux-u-boot-h616-current':
missing 'Description' field
Selecting previously unselected package mysql-common.
(Reading database ... 72697 files and directories currently installed.)
Preparing to unpack .../0-mysql-common_5.8+1.0.7_all.deb ...
Unpacking mysql-common (5.8+1.0.7) ...
Selecting previously unselected package mariadb-common.
Preparing to unpack .../1-mariadb-common_1%3a10.5.19-0+deb11u2_all.deb ...
Unpacking mariadb-common (1:10.5.19-0+deb11u2) ...
Selecting previously unselected package libmariadb3:arm64.
Preparing to unpack .../2-libmariadb3_1%3a10.5.19-0+deb11u2_arm64.deb ...
Unpacking libmariadb3:arm64 (1:10.5.19-0+deb11u2) ...
Selecting previously unselected package libmicrohttpd12:arm64.
Preparing to unpack .../3-libmicrohttpd12_0.9.72-2_arm64.deb ...
Unpacking libmicrohttpd12:arm64 (0.9.72-2) ...
Selecting previously unselected package libpq5:arm64.
Preparing to unpack .../4-libpq5_13.11-0+deb11u1_arm64.deb ...
Unpacking libpq5:arm64 (13.11-0+deb11u1) ...
Selecting previously unselected package motion.
Preparing to unpack .../5-motion_4.3.2-1_arm64.deb ...
Unpacking motion (4.3.2-1) ...
dpkg: warning: parsing file '/var/lib/dpkg/status' near line 15854 package 'linux-u-boot-h616-current':
missing 'Description' field
Setting up mysql-common (5.8+1.0.7) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up libpq5:arm64 (13.11-0+deb11u1) ...
Setting up libmicrohttpd12:arm64 (0.9.72-2) ...
Setting up mariadb-common (1:10.5.19-0+deb11u2) ...
update-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up libmariadb3:arm64 (1:10.5.19-0+deb11u2) ...
Setting up motion (4.3.2-1) ...
Adding group `motion' (GID 116) ...
Done.
Warning: The home dir /var/lib/motion you specified already exists.
Adding system user `motion' (UID 108) ...
Adding new user `motion' (UID 108) with group `motion' ...
The home directory `/var/lib/motion' already exists. Not copying from `/etc/skel'.
adduser: Warning: The home directory `/var/lib/motion' does not belong to the user you are currently creating.
Adding user `motion' to group `video' ...
Adding user motion to group video
Done.
Created symlink /etc/systemd/system/multi-user.target.wants/motion.service → /lib/systemd/system/motion.service.
Broadcast message from systemd-journald@BTT-CB1 (Thu 2023-07-06 01:06:05 UTC):
motion[10216]: [0:motion] [EMG] [ALL] motion_startup: Exit motion, cannot create log file /var/log/motion/motion.log: Permission denied
Processing triggers for libc-bin (2.31-13+deb11u6) ...
2.2、修改etc/default/motion配置
biqu@BTT-CB1:~$ vi /etc/default/motion
修改start_motion_daemon=yes
文件中没有此文件的,要创建此文件
2.3、修改etc/motion/motion.conf
biqu@BTT-CB1:~$ vi /etc/motion/motion.conf
修改下面两个选项
2.4、测试
执行启动命令
biqu@BTT-CB1:~$ sudo motion
在浏览器地址栏输入开发板的IP:8081
实时查看摄像头数据,这个软件延时有点严重,总是卡顿。
关闭motion命令
biqu@BTT-CB1:~$ sudo killall -TERM motion
本帖最后由 TL-LED 于 2023-7-6 09:43 编辑
引用: 吾妻思萌 发表于 2023-7-6 16:02 FPS是不是8-10?我之前pi的摄像头就是速度慢慢
使用的USB摄像头,移植motion这个软件,测试有点卡,摄像头本身速度还可以
你用的motion是局域网的形式吧?怎么会卡呢。
引用: wangerxian 发表于 2023-7-7 09:32 你用的motion是局域网的形式吧?怎么会卡呢。
是局域网,这个软件测试过后,都觉得有点卡。
引用: TL-LED 发表于 2023-7-7 09:37 是局域网,这个软件测试过后,都觉得有点卡。
那估计就是这个软件的数据传输和图像没有做好。