本文主要是介绍v4l2摄像头移植mjpg_streamer笔记,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
v4l2摄像头移植mjpg_streamer笔记 mjpg-stream的移植需要jpeg的库,所以我们先移植jpeg的库
(1)jpeg库的移植1)jpeg源码包通过下面这个网址下载http://www.ijg.org/files/jpegsrc.v8b.tar.gz2)解压源码包tar xvf jpegsrc.v8b.tar.gz3)配置源码cd jpeg-8b./configure --prefix=/home/6410/video/jpeg --host=arm-linux4)编译make5)安装make install6)拷贝libjpeg.s0.8库到开发板文件系统lib下中
mjpg-stream的移植1)mjpg-stream源码包通过下面这个网址下载http://sourceforge.net/projects/mjpg-streamer/ 2)解压源码tar xvf mjpg-streamer-r63.tar.gz3)修改源码cd mjpg-streamer-r63修改顶层makefile及plugins目录中的各级makefile将所有CC=gcc修改为CC=arm-none-linux-gnueabi-gcc修改plugins/input_uvc/Makfile修改CFLAGS += -O2 -DLINUX -D_GNU_SOURCE -Wall -shared -fPIC为CFLAGS += -O2 -DLINUX -D_GNU_SOURCE -Wall -shared -fPIC -I/home/6410/video/jpeg/include修改$(CC) $(CFLAGS) -ljpeg -o $@ input_uvc.c v4l2uvc.lo jpeg_utils.lo dynctrl.lo为$(CC) $(CFLAGS) -ljpeg -L/home/6410/video/jpeg/lib -o $@ input_uvc.c v4l2uvc.lo jpeg_utils.lo dynctrl.lo4)编译make5)测试在开发板上mkdir /mjpeg拷贝*.so到开发板的mjpeg目录下,mjpg_streamer到开发板的bin下并改变权限打开开开发板运行mjpg_streamer -i "/webcam/input_uvc.so -y -d /dev/video0" -o "/webcam/output_http.so"用火狐浏览器打开一个网页输入下面地址就能够看到一个视频(开发板的IP为222.22.253.88):http://222.22.253.88:8080/?action=stream 打开一个网页输入下面地址就能够看到一个静态图片:http://222.22.253.88:8080/?action=snapshot ---------------------------------------------------------------------------
经常出的问题:
问1:由于摄像头驱动为v4l2架构的,所以安装mjpg_streamer视频服务器,但是运行mjpg_streamer出现如下错误?
# mjpg_streamer
Jan 14 01:57:37 MJPG-streamer [638]: starting application
MJPG Streamer Version.: 2.0
Jan 14 01:57:37 MJPG-streamer [638]: MJPG Streamer Version.: 2.0ERROR: could not find input plugin
Jan 14 01:57:37 MJPG-streamer [638]: ERROR: could not find input pluginPerhaps you want to adjust the search path with:
Jan 14 01:57:37 MJPG-streamer [638]: Perhaps you want to adjust the search path with:# export LD_LIBRARY_PATH=/path/to/plugin/folder
Jan 14 01:57:37 MJPG-streamer [638]: # export LD_LIBRARY_PATH=/path/to/plugin/folderdlopen: File not found
Jan 14 01:57:37 MJPG-streamer [638]: dlopen: File not found网友说找不到共享库路径,但是已经添加了/mjpeg/,还是出现这个问题,请问怎么回事?
下面是共享库的环境变量
export LD_LIBRARY_PATH='/mjpeg:/lib'# ls /mjpeg/ -l
total 344
-rwxrwxrwx 1 root root 61423 Jan 13 23:59 input_gspcav1.so
-rwxrwxrwx 1 root root 168284 Jan 13 23:59 input_testpicture.so
-rwxrwxrwx 1 root root 27718 Jan 13 23:59 input_uvc.so
-rwxrwxrwx 1 root root 14736 Jan 14 00:01 mjpg_streamer
-rwxrwxrwx 1 root root 29420 Jan 13 23:59 output_autofocus.so
-rwxrwxrwx 1 root root 11958 Jan 13 23:59 output_file.so
-rwxrwxrwx 1 root root 23726 Jan 13 23:59 output_http.so
-rwxr-xr-x 1 root root 3436 Jan 14 01:06 start.sh答1: 肯定不是共享库路径的问题了,mjpg_streamer -i "input_testpicture.so",可以正常运行,那就排除库的路径问题了sean@ubuntu:~/work/cx92755/rishun_driver/web_cam/mjpg-streamer-r63$ file input_uvc.so input_testpicture.so input_gspcav1.so input_uvc.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not strippedinput_testpicture.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not strippedinput_gspcav1.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, not stripped查看动态库也都是一样的,通过readelf -d input_uvc.so 发现了问题
sean@ubuntu:~/work/cx92755/rishun_driver/web_cam/mjpg-streamer-r63$ readelf -d input_uvc.so Dynamic section at offset 0x4898 contains 25 entries:Tag Type Name/Value0x00000001 (NEEDED) Shared library: [libjpeg.so.8] //需要依赖的库,然而这个库文件跟我编译jpeg库文件名称不同,修改库文件名称就搞定。0x00000001 (NEEDED) Shared library: [libc.so.0] //需要依赖的库0x0000000c (INIT) 0x11440x0000000d (FINI) 0x3bf80x00000019 (INIT_ARRAY) 0xc8200x0000001b (INIT_ARRAYSZ) 4 (bytes)0x0000001a (FINI_ARRAY) 0xc8240x0000001c (FINI_ARRAYSZ) 4 (bytes)0x00000004 (HASH) 0xb40x00000005 (STRTAB) 0x8f80x00000006 (SYMTAB) 0x3380x0000000a (STRSZ) 1049 (bytes)0x0000000b (SYMENT) 16 (bytes)0x00000003 (PLTGOT) 0xc9800x00000002 (PLTRELSZ) 520 (bytes)0x00000014 (PLTREL) REL0x00000017 (JMPREL) 0xf3c0x00000011 (REL) 0xdec0x00000012 (RELSZ) 336 (bytes)0x00000013 (RELENT) 8 (bytes)0x6ffffffe (VERNEED) 0xdcc0x6fffffff (VERNEEDNUM) 10x6ffffff0 (VERSYM) 0xd120x6ffffffa (RELCOUNT) 300x00000000 (NULL) 0x0问2:在服务器上运行 mjpg_streamer -i "/webcam/input_uvc.so -d /dev/video0" -o "/webcam/output_http.so" ,在firefox浏览器上运行出现全黑?
答2:由于mjpg_streamer软件支持两种编码格式jpeg和yuv格式,如果摄像头是yuv格式,添加-y就可以了服务器端 mjpg_streamer -i "/webcam/input_uvc.so -y -d /dev/video0" -o "/webcam/output_http.so" 客户端 地址栏输入 http://192.168.8.15:8080/?action=stream 服务器端 mjpg_streamer -i "/webcam/input_uvc.so -y -d /dev/video0" -o "/webcam/output_http.so -w `pwd`/www"
这篇关于v4l2摄像头移植mjpg_streamer笔记的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!