v4l2摄像头移植mjpg_streamer笔记

来源:互联网 发布:最新专业网络投资理财 编辑:程序博客网 时间:2024/05/16 01:14
v4l2摄像头移植mjpg_streamer笔记mjpg-stream的移植需要jpeg的库,所以我们先移植jpeg的库 (1)jpeg库的移植         1)jpeg源码包通过下面这个网址下载                http://www.ijg.org/files/jpegsrc.v8b.tar.gz                2)解压源码包                tar xvf jpegsrc.v8b.tar.gz                3)配置源码                cd jpeg-8b                ./configure --prefix=/home/6410/video/jpeg --host=arm-linux                4)编译                make                5)安装                make install                6)拷贝libjpeg.s0.8库到开发板文件系统lib下中mjpg-stream的移植         1)mjpg-stream源码包通过下面这个网址下载                http://sourceforge.net/projects/mjpg-streamer/                 2)解压源码                tar xvf mjpg-streamer-r63.tar.gz                3)修改源码                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.lo                4)编译                make                5)测试                在开发板上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 applicationMJPG Streamer Version.: 2.0Jan 14 01:57:37 MJPG-streamer [638]: MJPG Streamer Version.: 2.0ERROR: could not find input pluginJan 14 01:57:37 MJPG-streamer [638]: ERROR: could not find input plugin       Perhaps 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/folderJan 14 01:57:37 MJPG-streamer [638]:        # export LD_LIBRARY_PATH=/path/to/plugin/folder       dlopen: File not foundJan 14 01:57:37 MJPG-streamer [638]:        dlopen: File not found网友说找不到共享库路径,但是已经添加了/mjpeg/,还是出现这个问题,请问怎么回事?下面是共享库的环境变量export LD_LIBRARY_PATH='/mjpeg:/lib'# ls /mjpeg/ -ltotal 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/Value 0x00000001 (NEEDED)                     Shared library: [libjpeg.so.8]//需要依赖的库,然而这个库文件跟我编译jpeg库文件名称不同,修改库文件名称就搞定。 0x00000001 (NEEDED)                     Shared library: [libc.so.0]//需要依赖的库 0x0000000c (INIT)                       0x1144 0x0000000d (FINI)                       0x3bf8 0x00000019 (INIT_ARRAY)                 0xc820 0x0000001b (INIT_ARRAYSZ)               4 (bytes) 0x0000001a (FINI_ARRAY)                 0xc824 0x0000001c (FINI_ARRAYSZ)               4 (bytes) 0x00000004 (HASH)                       0xb4 0x00000005 (STRTAB)                     0x8f8 0x00000006 (SYMTAB)                     0x338 0x0000000a (STRSZ)                      1049 (bytes) 0x0000000b (SYMENT)                     16 (bytes) 0x00000003 (PLTGOT)                     0xc980 0x00000002 (PLTRELSZ)                   520 (bytes) 0x00000014 (PLTREL)                     REL 0x00000017 (JMPREL)                     0xf3c 0x00000011 (REL)                        0xdec 0x00000012 (RELSZ)                      336 (bytes) 0x00000013 (RELENT)                     8 (bytes) 0x6ffffffe (VERNEED)                    0xdcc 0x6fffffff (VERNEEDNUM)                 1 0x6ffffff0 (VERSYM)                     0xd12 0x6ffffffa (RELCOUNT)                   30 0x00000000 (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" 

1 0
原创粉丝点击