Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

全志V3S移植mjpg-streamer #31

Open
Meekdai opened this issue Oct 7, 2023 · 0 comments
Open

全志V3S移植mjpg-streamer #31

Meekdai opened this issue Oct 7, 2023 · 0 comments
Labels

Comments

@Meekdai
Copy link
Owner

Meekdai commented Oct 7, 2023

上一篇文章在树莓派上简单的测试了一下USB摄像头通过mjpg-streamer推流的步骤,本篇记录使用全志的V3S替代树莓派实现这个功能。由于树莓派上有包管理工具,所以可以直接使用apt-get指令来安装需要的软件脚本,但是V3S没有包管理,需要自己移植并且交叉编译。

本篇文章是一个巨坑,请谨慎参考

下一篇文章会填坑:多USB摄像头在同一USB总线上开启


一、开发环境

开发板:荔枝派zero
buildroot:2018.08.2
FLASH:32M
编译环境:WIN10 WSL 和 Github Codepaces

具体参考:V3s buildroot 一键生成打包生成32M spi flash 镜像, jffs2 文件系统, 默认启动 Qt 模拟时钟demo,

二、开启UVC摄像头

进入linux-zero-4.13.y目录,可通过make menuconfig启用,也可以直接编辑.config文件,主要是启用 UVCV4L2

具体参考1:嵌入式Linux平台下的UVC驱动和V4L2
具体参考2:关于V3S使用usb摄像头的问题
具体参考3:V3S插入USB设备没有反应
具体参考4:荔枝派Zero(全志V3S)驱动开发之USB摄像头
具体参考5:Linux UVC driver and tools
具体参考6:荔枝派Zero(全志V3S)驱动开发之USB摄像头 1

三、交叉编译mjpg-streamer

libjpeg库安装

  1. 下载 jpegsrc.v9e.tar.gz
  2. 解压 tar -vxzf jpegsrc.v9e.tar.gz
  3. 配置 ./configure CC=/mnt/d/MICROPYTHON/V3S/gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc --prefix=$PWD/_install --host=arm-linux-gnueabihf --enable-shared --enable-static
  4. 编译 make
  5. 安装 make install

mjpg-streamer编译

  1. 下载 https://sourceforge.net/p/mjpg-streamer/code/HEAD/tree/
  2. 进入mjpg-streamer目录,修改plugins目录下的makefile文件,指向自己的路径。
# CFLAGS += -O1 -DLINUX -D_GNU_SOURCE -Wall -shared -fPIC
CFLAGS += -O1 -DLINUX -D_GNU_SOURCE -Wall -shared -fPIC -I /mnt/c/Users/Meekdai/Desktop/v3s/app/tools/jpeg-9e/_install/include
input_uvc.so: $(OTHER_HEADERS) input_uvc.c v4l2uvc.lo jpeg_utils.lo dynctrl.lo
	$(CC) $(CFLAGS) -L /mnt/c/Users/Meekdai/Desktop/v3s/app/tools/jpeg-9e/_install/lib -o $@ input_uvc.c v4l2uvc.lo jpeg_utils.lo dynctrl.lo $(LFLAGS)
  1. 根据需要编译下面的插件,内容在主Makefile里。
# define the names and targets of the plugins
PLUGINS = input_uvc.so
PLUGINS += output_file.so
PLUGINS += output_udp.so
PLUGINS += output_http.so
PLUGINS += input_testpicture.so
#PLUGINS += output_autofocus.so
#PLUGINS += input_gspcav1.so
PLUGINS += input_file.so
PLUGINS += output_rtsp.so
# PLUGINS += output_ptp2.so # commented out because it depends on libgphoto
# PLUGINS += input_control.so # commented out because the output_http does it's job
# PLUGINS += input_http.so 
# PLUGINS += output_viewer.so # commented out because it depends on SDL
  1. 然后执行make CC=/mnt/d/MICROPYTHON/V3S/gcc-linaro-6.3.1-2017.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc编译,结束后拷贝文件到V3S中:
jpeg-9d/_install 的/lib/下的库文件拷贝到开发板的/lib/目录下
*.so 文件拷贝到开发板的/lib/目录下
mjpg_streamer 文件拷贝到开发板的/bin/目录下
www 文件夹拷贝到/opt/目录下

具体参考1:荔枝派Zero(全志V3S)驱动开发之RGB LCD屏幕显示jpg图片
具体参考2:荔枝派Zero(全志V3S)驱动开发之USB摄像头 2
具体参考3:mjpeg-streamer交叉编译

四、运行mjpg-streamer

mjpg_streamer -i "input_uvc.so -d /dev/video0 -n -f 10 -r 1280x720 -yuv" -o "output_http.so -p 8080 -w /opt/www"

如果报权限的错误,执行 chmod 777 /bin/mjpg_streamer
然后访问:http://192.168.10.35:8080

五、其他

  1. 使能以太网(4.13-y版本)
#打开网络
#设置ip
#设置网关

ifconfig eth0 up
ifconfig eth0 192.168.10.35
route add default gw 192.168.10.1
  1. 查看USB设备和摄像头
lsusb
ls /dev/video*
  1. 报错Unsupported relocation type: R_X86_64_PLT32 (4) 解决方案:x86: Treat R_X86_64_PLT32 as R_X86_64_PC32

  2. 编译指令

#解压
tar xvf  backup_20190220A.tgz

#执行一次 make (约2小时)
make

#再次解压覆盖文件, 编译(约5分钟)
sh ./pre_build.sh
make

#打包
sh ./pack.sh

@Meekdai Meekdai added the 软件 label Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant