- 论坛徽章:
- 0
|
开发板上的arm是AT91RM9200,摄像头选用的是网眼的pc350,主控芯片是ov511+。系统内核是2.4,宿主机是fedora core 6,交叉编译器是2.95.3。就是这些家底了,:-)。
一 驱动加载 ov511的驱动,2.4的内核中就有,所以我们只需重新编译内核,将下边的选项都选上,然后重新烧写内核就可以了。:-),也就是直接静态加载,我喜欢一劳永逸,:-),试验阶段还是动态的好。 (1)在arm linux的kernel目录下make menuconfig。 (2)首先(*)选择Multimedia device->下的Video for linux。加载video4linux模块,为视频采集设备提供编程接口; (3)然后在usb support->目录下(*)选择support for usb和usb camera ov511 support。这使得在内核中加入了对采用OV511接口芯片的USB数字摄像头的驱动支持。 (4)保存配置退出。 (5)make dep;make zImage就生成了带有ov511 驱动的内核。 接下来就通过uboot将内核烧到flash里去。这时你将摄像头插上,系统就会提示发现摄像头-ov511+,这说明驱动正常。:-),驱动加载就成功了,下一步就是图像采集了。
二 图像获取
关于图像采集,我用的是一个开源软件,就是德国人做的抓图程序:vgrabbj。
http://vgrabbj.gecius.de/ 第一步当然就是down下来,然后交叉编译了,可是不幸的是我们的编译器就是那个伟大的2.95.3里东东不够多,缺少一些库文件了(zlib,jpge,png)。所以我们首先要充实一下自己的家底,交叉编译这三个库文件了。 1.首先安装 zlib 库,这个是后面的库的编译基础。这个是下载地址: http://www.zlib.net/zlib-1.2.3.tar.gz 400多K,去下载吧。 解压 # tar -zxvf zlib-1.2.3.tar.gz 进入zlib-1.2.3目录下 #cd zlib-1.2.3 配置,由于 zlib 库的configure 脚本不支持交叉编译选项,所以我们首先设置CC # export CC=arm-linux-gcc # ./configure --prefix=/usr/local/arm/2.95.3/arm-linux/ --shared 注意:prefix就是安装目录,这里配置指向 /usr/local/arm/2.95.3/arm-linux/ 目录,就会自动安装在 /usr/local/arm/2.95.3/arm-linux/ [include,lib] 目录下,千万不要装错目录了,不然后面会找不到这个库的 # make # make install 安装完后检查一下目录 /usr/local/arm/2.95.3/arm-linux/ [include,lib] ,假如 include 中没有 zlib.h 之类的头文件,lib 中没有 libz.so.1.2.3 ,那就自己手动拷到这些目录下去,记着拷的时候把所有的 *.h 都需要拷过去,在拷库的时候用 cp –a libz.* /…./lib 就行,要用上 –a 选项。这样zlib就搞定了。 2.安装 png 库,这个是用来显示 png 图形的,下载地址: http://superb-east.dl.sourceforge.net/sourceforge/libpng/libpng-1.0.10rc1.tar.gz
# tar zxf libpng-1.0.10rc1.tar.gz # cd libpng-1.0.10rc1 Libpng 不提供有效的 configure 脚本,所以只好自己动手改 Makefile 文件了 # cp scripts/makefile.linux Makefile //把 Scripts下的一个 makefile 拷出来自己动手改 # vi Makefile // 自己动手改 CC=arm-linux-gcc //修改这里 # where "make install" puts libpng.a, libpng.so*, png.h and pngconf.h prefix=/usr/local/arm/2.95.3/arm-linux //修改这里 # Where the zlib library and include files are located #ZLIBLIB=/usr/local/lib #ZLIBINC=/usr/local/include ZLIBLIB=/usr/local/arm/2.95.3/arm-linux/lib //修改这里 ZLIBINC=/usr/local/arm/2.95.3/arm-linux/include //修改这里 好了,保存,然后去编译吧 # make # make install 如果有错误,检查你前面的步骤哪个没做对 ,:-) 尤其是 zlib 的安装 还是前面说的,检查 /usr/local/arm/2.95.3/arm-linux/ [include,lib] 目录中有成功安装否,如果没有安装成功,那就自己把编译出来的东西拷过去。记着,*.h 和 .so 的文件都要拷。
3.安装 jpeg 库 ,下载地址: ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz # tar -zxvf jpegsrc.v6b.tar.gz # cd jpeg-6b # ./configure --help //可以查看它的配置选项 # export CC=arm-linux-gcc # ./configure --prefix=/usr/local/arm/2.95.3/arm-linux/ --enable-shared --enable-static 然后我们需要修改一下makefile文件,因为我的系统的libtool好像和这个版本配合的不是很好。下边这些地方是需要注意的,:-),尤其是libtool,如果你的也工作不好的话。 # Where to install the programs and man pages. prefix = /usr/local/arm/2.95.3/arm-linux # The name of your C compiler: CC= arm-linux-gcc # If using GNU libtool, LIBTOOL references it; if not, LIBTOOL is empty. LIBTOOL = # $(O) expands to "lo" if using libtool, plain "o" if not. # Similarly, $(A) expands to "la" or "a". O = o A = a # library (.a) file creation command AR= arm-linux-ar rc # second step in .a creation (use "touch" if not needed) AR2= arm-linux-ranlib # make 安装前需要在 arm-linux 下建个目录,不然安装会出错 # mkdir –p /usr/local/arm/2.95.3/arm-linux/man/man1 # make install // OK 了 一样,自己去检查一下安装是否成功,:-),库文件终于告一段落了。下边到我们的主角了,vgrabbj。
4.交叉编译vgrabbj # tar -zxvf vgrabbj-0.9.6.tar.gz # cd vgrabbj-0.9.6 # ./configure --help #export CC=arm-linux-gcc #mkdir myvgr #./configure --host=arm-linux --prefix=./myvgr --disable-ftp --disable-timestamp 去掉不需要的选项吧,多了不一定可以的,:-)。 修改makefile #vim Makefile CFLAGS = -g -O2 -Wall -I/home/linux-2.4/include 添加斜体部分,:-)。 [root@localhost vgrabbj-0.9.6]# make [root@localhost vgrabbj-0.9.6]# make install 好了,这样你就在myvgr中有了一个vgrabbj可执行文件,把它下到开发板上就可以采集图像了。
5.vgrabbj的使用 vgrabbj需要两个动态库文件,所以首先拷贝到开发板上,:-)。如下: [root@(none) lib]$cp -a libpng.so.2 /lib [root@(none) lib]$cp -a libpng.so.2.1.0.10rc1 /lib [root@(none) lib]$cd myvgr [root@(none) myvgr]$ls bin etc lib man [root@(none) myvgr]$cd bin [root@(none) bin]$ls vgrabbj [root@(none) bin]$./vgrabbj --help Usage: vgrabbj [options] -h This screen -c parse as config file -l Daemonize & sleep (min. 1!) between images -L Daemonize & sleep between images -a Switch vgrabbj's auto brightness adjustment (default: off) You might need to set -F 4, too, if it doesn't work -q Quality setting (0-100, default: 75), JPEG only -i Sets the imagesize of input device to sqcif=128x96,qsif=160x120,qcif=176x144, sif=320x240, cif=352x288, vga=640x480, svga=800x600, xga=1024x768, sxga=1280x1024, or uxga=1600x1200 (default:352x288) -o Output format (default:jpg) -f Write to (default: /dev/stdout) -d Read from as input (default: /dev/video) Example: vgrabbj -l 5 -f /usr/local/image.jpg Would write a single jpeg-image to image.jpg approx. every five seconds [root@(none) bin]$./vgrabbj -f ./1.jpg -d /dev/v4l/video0 Could not open configfile ./myvgr/etc/vgrabbj.conf, ignoring Reading image from /dev/v4l/video0 [root@(none) bin]$./vgrabbj -f ./2.jpg -d /dev/v4l/video0 Could not open configfile ./myvgr/etc/vgrabbj.conf, ignoring Reading image from /dev/v4l/video0 你把1.jpg,2.jpg拷到宿主机上,就可以看到自己的劳动成果了,:-)。
感谢大漠孤狼,关于库的编译,我主要参考了他的文章。当然还有其他大侠的,:-),就不写了。 MiniGUI 1.3.3 移植详解 作者:大漠孤狼 E-Mail: yuqiang0107@126.com <IMG onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmousewheel="return imgzoom(this);" onclick="if(!this.resized) {return true;} else {window.open('http://control.cublog.cn/fileicon/rar.gif');}" border=0 alt="" src="http://control.cublog.cn/fileicon/rar.gif" onload="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}"> 文件: vgrabbj.rar 大小: 162KB 下载: 下载
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/22630/showart_324397.html
|
|