基于Tiny210的图像采集
1、串口终端
CMOS 树莓派 OV7670摄像头
[root@FriendlyARM web-cam]# [15279.408438] usb 1-1.3: new high speed USB device
number 5 using s5p-ehci
[15279.598686] uvcvideo: Found UVC 1.00 device Sirius USB2.0 Camera (0ac8:3330)
[15279.608481] input: Sirius USB2.0 Camera as /devices/platform/s5p-ehci/usb1/1-
1/1-1.3/1-1.3:1.0/input/input5
Step 1:将 mjpg-streamer-smart210-broadon-bin.tar.gz 压缩包通过 SD 卡
或通过 NFS 网络文件系统的方式拷贝到开发板的根文件系统下。
Step 2:在开发板的 mjpg-streamer-smart210-broadon-bin.tar.gz 压缩包
路径处解压缩。
tar zxf mjpg-streamer-smart210-broadon-bin.tar.gz
Step 3:将 USB 摄像头接到开发板上,执行如下代码:
./ start_uvc.sh
出错:
[root@FriendlyARM web-cam]# ./start_uvc.sh
MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video3
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i: Format............: MJPG
Unable to set format: Invalid argument
Init v4L2 failed !! exit fatal
i: init_VideoIn failed
[root@FriendlyARM web-cam]#
解决:
G:\Tiny210---1\smart210\sources\mjpg-streamer-smart210-broadon-src\plugins\input_uvc
vim input_uvc.c
format = V4L2_PIX_FMT_MJPEG改为:
format = V4L2_PIX_FMT_YUYV
int input_init(input_parameter *param) {
char *argv[MAX_ARGUMENTS]={NULL}, *dev = "/dev/video0", *s;
int argc=1, width=640, height=480, fps=5, format=V4L2_PIX_FMT_YUYV, i;
in_cmd_type led = IN_CMD_LED_AUTO;
char fourcc[5]={0,0,0,0,0};
/* initialize the mutes variable */
if( pthread_mutex_init(&controls_mutex, NULL) != 0 ) {
IPRINT("could not initialize mutex variable\n");
exit(EXIT_FAILURE);
}
cd mjpg-streamer-smart210-broadon-src
- 编译 mjpg-streamer 源代码,执行如下:
make
- 制作可执行文件及库的压缩包,执行如下:
- [friendlyarm@vmware mjpg-streamer-smart210-broadon-src]$ sudo -s
[friendlyarm@vmware ~]$ cd software/mjpg-streamer-smart210-broadon-src
[friendlyarm@vmware mjpg-streamer-smart210-broadon-src]$ make
arm-linux-gcc -O3 -DLINUX -D_GNU_SOURCE -Wall -c -o mjpg_streamer.o mjpg_streamer.c
make: arm-linux-gcc:命令未找到
[friendlyarm@vmware mjpg-streamer-smart210-broadon-src]$ sudo -s
[root@vmware mjpg-streamer-smart210-broadon-src]# make
arm-linux-gcc -O3 -DLINUX -D_GNU_SOURCE -Wall -c -o mjpg_streamer.o mjpg_streamer.c
arm-linux-gcc -O3 -DLINUX -D_GNU_SOURCE -Wall -c -o utils.o utils.c
arm-linux-gcc -O3 -DLINUX -D_GNU_SOURCE -Wall -lpthread -ldl mjpg_streamer.o utils.o -o mjpg_streamer
make package
- 制作生成的压缩包为:mjpg-streamer-smart210-broadon-bin.tar.gz
sudo su 和 sudo -s都是切换到root用户,不同的是:
sudo su 环境用的是目标用户(root)的环境
sudo -s 环境用的是当前用户本身的环境
错误:
[root@FriendlyARM web-cam]# ./start_uvc.sh
MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video3[ 380.919671] s3c-fimc-2 : fimc_s_fmt_vid_ca
pture: No capture device.
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i: Format............: YUYV
i: JPEG Quality......: 80
Unable to set format: No such device
Init v4L2 failed !! exit fatal
i: init_VideoIn failed
[root@FriendlyARM web-cam]# [ 407.428884] usb 1-1.3: USB disconnect, device num
ber 5
[root@FriendlyARM web-cam]# [ 421.453411] usb 1-1.4: new high speed USB device
number 6 using s5p-ehci
[ 421.643818] uvcvideo: Found UVC 1.00 device Sirius USB2.0 Camera (0ac8:3330)
[ 421.653525] input: Sirius USB2.0 Camera as /devices/platform/s5p-ehci/usb1/1-
1/1-1.4/1-1.4:1.0/input/input6
[root@FriendlyARM web-cam]# ./start_uvc.sh
MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video3[ 434.970289] s3c-fimc-2 : fimc_s_fmt_vid_ca
pture: No capture device.
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i: Format............: YUYV
i: JPEG Quality......: 80
Unable to set format: No such device
Init v4L2 failed !! exit fatal
i: init_VideoIn failed
[root@FriendlyARM web-cam]#
视频口为 /dev/video2, 插上板子中间的USB后:
network_latency tty24 usbdev1.1
null tty26 usbdev1.3
ppp tty27 usbdev1.5
psaux tty28 usbdev2.1
ptmx tty29 vcs
pts tty3 vcs1
ptyp0 tty30 vcs2
ptyp1 tty31 vcs3
ptyp2 tty32 vcs4
ptyp3 tty33 vcsa
ptyp4 tty34 vcsa1
ptyp5 tty35 vcsa2
ptyp6 tty36 vcsa3
ptyp7 tty37 vcsa4
ptyp8 tty38 video0
ptyp9 tty39 video1
ptypa tty4 video14
ptypb tty40 video2
ptypc tty41 video21
ptypd tty42 video22
ptype tty43 video3
ptypf tty44 watchdog
pvrsrvkm tty45 xt_qtaguid
pwm tty46 zero
[root@FriendlyARM /dev]#
拔出后:
null tty25 usbdev1.1
ppp tty26 usbdev1.2
psaux tty27 usbdev1.3
ptmx tty28 usbdev2.1
pts tty29 vcs
ptyp0 tty3 vcs1
ptyp1 tty30 vcs2
ptyp2 tty31 vcs3
ptyp3 tty32 vcs4
ptyp4 tty33 vcsa
ptyp5 tty34 vcsa1
ptyp6 tty35 vcsa2
ptyp7 tty36 vcsa3
ptyp8 tty37 vcsa4
ptyp9 tty38 video1
ptypa tty39 video14
ptypb tty4 video2
ptypc tty40 video21
ptypd tty41 video22
ptype tty42 video3
ptypf tty43 watchdog
pvrsrvkm tty44 xt_qtaguid
pwm tty45 zero
[root@FriendlyARM /dev]#
[root@FriendlyARM web-cam]# ls -lh /dev/video0
crw-rw---- 1 root root 81, 0 Apr 22 14:06 /dev/video0
[root@FriendlyARM web-cam]# [ 1038.708919] s3c-fimc-1 : fimc_open: Context busy
flag not reset.
[root@FriendlyARM web-cam]# ls -lh /dev/video2
crw-rw---- 1 root root 81, 2 Apr 22 2019 /dev/video2
视频口: /dev/video2 s3c-fimc-1
[root@FriendlyARM web-cam]# [ 1241.146563] s3c-fimc-1 : fimc_open: Context busy
flag not reset.
USB口: /dev/video0 s3c-fimc-2
[root@FriendlyARM web-cam]# ./start_uvc.sh
MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video3[ 1204.649228] s3c-fimc-2 : fimc_s_fmt_vid_ca
pture: No capture device.
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i: Format............: YUYV
i: JPEG Quality......: 80
Unable to set format: No such device
Init v4L2 failed !! exit fatal
i: init_VideoIn failed
解决 :
USB口为: /dev/video0
我们默认设置的是Using V4L2 device.: /dev/video3
解决办法:1)、进入/dev/,将video0改成video3,将video3改成video0
[root@FriendlyARM /dev]# mv video0 video3
[root@FriendlyARM yuyv-video0]# ls /dev/video*
/dev/video0 /dev/video14 /dev/video21
/dev/video1 /dev/video2 /dev/video22
错误:
[root@FriendlyARM yuyv-video3]# ./start_uvc.sh
MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video3
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i: Format............: YUYV
i: JPEG Quality......: 80
Unable to set format: Device or resource busy
Init v4L2 failed !! exit fatal
i: init_VideoIn failed
[root@FriendlyARM yuyv-video3]#
解决:
连接成功的显示:
[root@FriendlyARM web-cam]# ./start_uvc.sh
MJPG Streamer Version.: 2.0
i: Using V4L2 device.: /dev/video3
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 5
i: Format............: YUYV
i: JPEG Quality......: 80
[ 235.027576] uvcvideo: Deprecated UVCIOC_CTRL_{ADD,MAP_OLD,GET,SET} ioctls wil
l be removed in 2.6.42.
[ 235.027659] uvcvideo: See http://www.ideasonboard.org/uvc/upgrade/ for upgrad
e instructions.
o: www-folder-path...: ./www/
o: HTTP TCP port.....: 8080
o: username:password.: disabled
o: commands..........: enabled
问题:
[root@FriendlyARM /dev]# [ 3990.233611] s3c-fimc-1 : fimc_open: Context busy fla
g not reset.
[ 4005.040658] s3c-fimc-1 : fimc_open: Context busy flag not reset.
[ 4013.752343] s3c-fimc-1 : fimc_open: Context busy flag not reset.
参考:
https://blog.csdn.net/iteye_21199/article/details/82325592
https://ubuntuqa.com/article/2345.html
https://blog.csdn.net/weixin_39021016/article/details/80101531