




已阅读5页,还剩43页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
i 基于 arm 的图像采集系统 摘 要 近年来,随着科学技术的不断发展,人们对于生活的安全、方便、快捷的 要求越来越高,图像采集已经越来越多地用于智能家居、图像识别、环境监控 等领域。 本文通过研究当前数字图像采集系统的研究成果和发展趋势,设计了一种 基于 arm 的数字图像采集系统,论文重点研究了系统的软件实现 。为了克服传 统图像采集系统的不足,本文采用常见的 usb 摄像头作为图像采集设备,利用 fs_s5pc100 开发板进行操作系统移植, 采用 s5pc100 芯片直接控制 usb 摄像 头进行图像数据采集,经格式转化后,通过 lcd 控制器在液晶显示屏上显示。 该系统使用主控芯片完成了图像采集和传送,实现的系统贴近于生活,具有一 定的实用价值。 关键词:关键词:嵌入式;图像采集;s5pc100;usb image capture system based on arm ii abstract:in recent years, with the continuous development of science and technology,people have increasingly higher demands for security, convenience, speedy of life. image acquisition has been increasingly used in smart home, image recognition, environmental monitoring and other fields. in this paper, i will design a digital image acquisition system based on arm by studying the current research results and developing trend of digital image acquisition system,and i focus on the software implementation of the system .in order to overcome the deficiency of the traditional image acquisition system ,i choose usb camera as the image acquisition device ,and transplant os into the fs_s5pc100 board in this paper .the main control chip , s5pc100 ,controls the usb camera to capture image first,and then it changes the image format and controls the lcd displayer to show the picture . with the only main control chip ,the system can capture and display images , this makes the system have practical implications and more closer to our true life. keyword:arm ; image acquisition;s5pc100;usb iii 目 录 第 1 章 前言1 第 2 章 相关器件3 2.1 摄像头 3 2.2 显示器 5 第 3 章 总体设计.9 3.1 功能需求.9 3.2 工作原理.9 3.3 软硬件规划10 3.3.1 硬件规划10 3.3.2 软件规划10 第 4 章 硬件设计11 4.1 开发板 /结构体清零,去除脏数据 fmt.type = v4l2_buf_type_video_capture;/设置支持的视频捕获功能 fmt.fmt.pix.pixelformat = v4l2_pix_fmt_yuyv;/设置视频采集数据格 式 fmt.fmt.pix.height = video_height; /设置列分辨率 fmt.fmt.pix.width = video_width; /设置行分辨率 fmt.fmt.pix.field = v4l2_field_interlaced / 设置视频包含 top 和bottom field, 隔行交替,fields 的瞬间序依赖于当前 video 的标准。 然后利用命令 vidioc_s_fmt 进行设置:ioctl(camerafd, vidioc_s_fmt, g = (y - (88 * u) - (183 * v) 8; b = (y + (454 * u) 8; *(ptr+) = (r 255) ? 255 : (r 255) ? 255 : (g 255) ? 255 : (b 3) ); *(displaybuffer+) =( (r 在将 yuv 数据转换成 rgb 之后,存储在 displaybuffer 中,然后经由函数 get_display_buffer 调用本函数处理后送到 lcd 屏幕显示。 iv)获取显示数据函数:display_buffer *get_display_buffer(void) 本函数功能在于监控图像捕获是否超时,如若没有,则进行数据格式的转 换并返回所需要用于显示的 displaybuffer。设置超时操作如下: fd_zero( fd_set(camerafd, tv.tv_sec = 2; tv.tv_usec = 0; ret = select(camerafd + 1, 然后使用命令 vidioc_dqbuf 请求获取一帧视频数据信息,将得到的数据 copy 到一个数组中,然后将此数组数据作为源数据进行数据格式转换得到可以用 lcd 显示的图像数据。最后再次使用 vidioc_qbuf 命令实现循环采集。 v)关闭设备函数:int close_video(void) 本函数对应于初始化函数,包含关闭视频采集,关闭视频设备。关闭视频 采集采用命令 vidioc_streamoff 实现,此命令对应于 vidioc_streamon,操作 为:ioctl(camerafd, vidioc_streamoff, /文件描述符 long int screensize ;/显示设备的像素点 struct fb_var_screeninfo vinfo;/显示屏信息 unshort *fbp ;/起始操作地址 fb; 初始化函数包括: 打开帧缓存设备:fb-fbfd = open(path,o_rdwr);获取屏幕参数: ioctl(fb-fbfd,fbioget_vscreeninfo, screenbuf+; image += 2; 成都理工大学 2013 届本科毕业设计(论文) 34 iii)关闭设备函数:int screen_close(fb *fb) 本函数包含的功能为:解除内存映射(munmap) ,关闭设备。 解映射:munmap 函数原型:int munmap(void *start,size_t length),start 所指的映射内存起始地址,参数 length 是欲取消的内存大小。 关闭设备:close(fb-fbfd)。同视频关闭函数,最后也应该释放 fb 指针,并 且赋值为 null,防止野指针的出现。 结 论 本文通过对嵌入式系统的学习,最终设计了一个基于 arm 的嵌入式图像采 集系统。本设计中采用了 usb 摄像头采集外部的图像信息;采用 auo a043fw02 电阻触摸屏显示采集的图像信息。使用 s5pc100 芯片完成图像的采集、显示控 制以及图像格式转换。 在此次设计中我遇到了非常多的困难。 首先是对现有开发板以及主控芯片的学习,我在开发板官网上下载了对应 的操作手册以及芯片手册,查阅很多的资料学习 bootloader 的使用以及功能, 还学习了关于交叉编译环境的搭建。 其次是软件的设计,因为 linux 中对视频的操作需要 v4l2 驱动,首先需要 学习该驱动的架构以及功能,然后查阅资料学习 4l2 编程流程,其中最困难的 是各项参数的设置以及理解。在摄像头程序中还涉及图像格式转换,因为选用 的摄像头输出格式为 yuyv,而显示器支持的为 rgb565,需要编写算法进行转换。 在显示程序中,查阅资料了解像素点色深度,解决了颜色显示失真的问题。 经过几个月的不断努力,最终基本实现了预期目标,完成系统的硬件学习, 软件设计,实现了图像信号的采集和显示。在毕业设计的整个设计过程中,发 现自己知识面还很窄。在以后的工作学习中,我将继续完善自己,努力做出用 户满意的系统。 成都理工大学 2013 届本科毕业设计(论文) 35 致 谢 时间飞逝,我的大学生活也随着毕业设计进行而将结束。在此我要感谢成 都理工大学为我们提供了良好的学习环境,使我们能够在此专心学习,陶冶情 操。大学四年来在学习上给了我帮助和支持的老师们,他们严肃的科学态度, 严谨的治学精神,精益求精的工作作风时刻提醒我要严格要求自己,不断取得 进步。正是在他们的谆谆教导下,我对论文中所涉及到的知识进行了深入的研 究,您们丰富的实践经验使我学到了很多课本上学不到的东西。同时还在思想、 生活上给了我无为不至的关怀,有了他们的鼓励和支持,我才克服了一个又一 个的困难和疑惑。在此对他们表示诚挚的谢意。 在这次毕业设计过程中得到了很多老师和同学的支持和鼓励。尤其是黄虎 老师。黄老师期间及时通知我学校下达的各项通知。在选题方面给了我很多建 议,并指导我如何开展毕业设计,在此期间给予了我很多的帮助。在此对黄老 师表示诚挚的谢意和崇高的敬意。 同时,设计期间还得到多位同学的帮助,在此对他们表示感谢。 由于我的水平有限,所写论文难免有不足之处,恳请各位老师和学友批评 指正。 成都理工大学 2013 届本科毕业设计(论文) 36 参考文献 1 程昌南,方强arm linux入门与实践m北京航空航天大学出版社, 2008 2 基于 arm cortex a8 的移动应用处理器 s5pc100.j 中国公共安全. 2010(20) 3 周立功,陈明计,陈渝arm 嵌入式 linux 系统构建与驱动开发范例 m北京:北京航空航天,2005 4 jonathan corbel alessandro rubini,greg kroah-hartman 著,魏永明 等译,linux 设备驱动程序(第三版)m北京:中国电力出版社,2002 5 neil matthew,richard stonesbeginning linux programmingm北京: 人民邮电出版社,2007 6宋宝华.linux 设备驱动开发详解m.北京:人民邮电出版社,2011 7曾宏安.嵌入式 linux c 语言开发m.北京:人民邮电出版社,2009 8刘洪涛.arm 嵌入式体系结构与接口技术m.北京:人民邮电出版社,2009 9马忠梅, 嵌入式处理器与嵌入式系统 m.电子世界,2003-3 10穆煜,嵌入式应用程序设计m.北京:人民邮电出版社,2009 11林晓飞,刘彬,张辉基于 arjvi 嵌入式 linux 应用开发与实例教程 m清华大学出版 社.2007 12yang xiaofei,deng jian,liao junqingfunction development of usb host in embedded systemjhuazhong keji daxue xuebao(ziran kexue ban)journal of huazhong university of science and technology(natural science edition),v 34,n 7,july 2006:79-81, 13liu junliang,pan gang,li pingembedded linux graphic terminal designb ased on arm j2006 chinese control conference proceedings,ccc 2006:19211925 14黄睿邦,汤采江,李文亮.linux 下基于 video4linux 的 usb 摄像头视频采集 实现j.现代计算机开发案例,2009,(309):182-184. 15 王俊.基于嵌入式 linux 视频监控传输系统的设计与实现j/ol.digital technology and application, (2013-1) /periodical_szjsyyy201301100.aspx 成都理工大学 2013 届本科毕业设计(论文) 37 附录:程序 1、头文件 image.h #ifndef image_h_ #define image_h_ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef unsigned short unshort;typedef unsigned char unchar; typedef struct fb int fbfd ; long int screensize ; struct fb_var_screeninfo vinfo; unshort *fbp ; fb; #define err_exit(function) do fprintf(stderr, “in %s at %s %d:n%s : %sn“, _function_, _file_, _line_, function, strerror(errno); exit(exit_failure); while(0) fb *screen_init(fb *fb);/open,get_msg,mmap int show_picture(fb *fb,int wide,int hight,const unchar *image);/display pictures #endif 2、video.c #include “image.h“#define output_buf_size 4096*3 typedef struct videobuffer 成都理工大学 2013 届本科毕业设计(论文) 38 void *start; size_t length; videobuffer; send_buffer displaybuffer; static int camerafd = -1; static videobuffer current_buffer; int video_height = 240; int video_width = 320;static struct v4l2_fmtdesc fmtdesc; static struct v4l2_capability capability; static v4l2_std_id v4l2_std; static struct v4l2_format fmt;static struct v4l2_requestbuffers v4l2_reqbuf; static videobuffer *buffers;static struct v4l2_buffer v4l2_buf; static enum v4l2_buf_type v4l2_type;static fd_set fds; static struct timeval tv; typedef struct struct jpeg_destination_mgr pub; joctet * buffer; unsigned char *outbuffer; int outbuffer_size; unsigned char *outbuffer_cursor; int *written; mjpg_destination_mgr; typedef mjpg_destination_mgr *mjpg_dest_ptr; static struct jpeg_compress_struct cinfo; static struct jpeg_error_mgr jerr;static jsamprow row_pointer1; static unsigned char *src_jpeg;static unsigned char *dest_jpeg; static int compress_ratio = 80; /define compress ratio. mjpg_dest_ptr dest = (mjpg_dest_ptr) cinfo-dest; size_t datacount = output_buf_size - dest-pub.free_in_buffer; /* write any data remaining in the buffer */ memcpy(dest-outbuffer_cursor, dest-buffer, datacount); dest-outbuffer_cursor += datacount; *(dest-written) += datacount; static void dest_buffer( unsigned char *buffer, int size,int *written) rgb_dest_ptr dest; dest = (rgb_dest_ptr) cinfo-dest; dest-pub.init_destination = init_destination; dest-pub.empty_output_buffer = empty_output_buffer; dest-pub.term_destination = term_destination; dest-outbuffer = buffer; dest-outbuffer_size = size; dest-outbuffer_cursor = buffer; dest-written = written; static int change_yuyv_to_rgb(unsigned char *primitive_data, unsigned char *compressed_data, int num_pixel, int quality) 成都理工大学 2013 届本科毕业设计(论文) 39 int ret, z;unsigned char *line_buffer, *yuyv; static int written;line_buffer = calloc(video_width * 3, 1); assert(line_buffer);yuyv = primitive_data; printf(“change start.n“);st_buffer( cinfo.image_width = video_width;cinfo.image_height = video_height; cinfo.input_components = 3; cinfo.in_color_space = jcs_rgb; z = 0; while (cinfo.next_scanline 8; g = (y - (88 * u) - (183 * v) 8; b = (y + (454 * u) 8; *(ptr+) = (r 255) ? 255 : (r 255) ? 255 : (g 255) ? 255 : (b 3) ); *(displaybuffer+) =( (r row_pointer0 = line_buffer; free(line_buffer); if (9999999 8) if (-1 = ioctl(camerafd, vidioc_querycap, exit(exit_failure); if (!(capability.capabilities exit(exit_failure); if (!(capability.capabilities exit(exit_failure); /set the frame format. memset( fmt.type = v4l2_buf_type_video_capture; fmt.fmt.pix.pixelformat = v4l2_pix_fmt_yuyv; fmt.fmt.pix.height = video_height; fmt.fmt.pix.width = video_width; fmt.fmt.pix.field = v4l2_field_interlaced; ret = ioctl(camerafd, vidioc_s_fmt, if (ret) 成都理工大学 2013 届本科毕业设计(论文) 41 perror(“ioctl:vidioc_s_fmt“); close(camerafd); exit(exit_failure); int file_length = fmt.fmt.pix.bytesperline * fmt.fmt.pix.height; printf(“the size of image is 0x%x bytesn“, file_length); printf(“bytes per line is %d, height is %d, width is %dn“, fmt.fmt.pix.bytesperline,fmt.fmt.pix.height, fmt.fmt.pix.width); /require the buffers from camera. memset( v4l2_reqbuf.count = 4; v4l2_reqbuf.type = v4l2_buf_type_video_capture; v4l2_reqbuf.memory = v4l2_memory_mmap; if (-1 = (ioctl(camerafd, vidioc_reqbufs, close(camerafd); exit(exit_failure); printf(“number of buffers : %dn“, v4l2_reqbuf.count); /mmap the buffer required. buffers = calloc(v4l2_reqbuf.count, sizeof(videobuffer); for (num_bufs = 0; num_bufs fbfd = open(path,o_rdwr); if(!fb-fbfd)err_exit(“fb_open“); printf(“the framebuffer device was opened sucessfullyn“); return fb; static fb *get_fb_msg(fb *fb)/get variable screen information if(ioctl(fb-fbfd,fbioget_vscreeninfo, fb-screensize = fb-vinfo.xres * fb-vinfo.yres * fb-vinfo.bits_per_pixel / 8; return fb; 成都理工大学 2013 届本科毕业设计(论文) 44 static fb *fb_mma
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 汉字的由来和演变
- 云南省曲靖市民族中学2024-2025学年高一上学期期中检测化学试卷(含答案)
- 内蒙古鄂尔多斯市西四旗2024-2025学年高一下学期7月期末考试生物试卷(含答案)
- 福建省漳州第一中学2024-2025学年高二下学期期末考试化学试题(含答案)
- 年眼科护士工作总结
- 虚拟现实技术在娱乐产业的运用
- 餐饮连锁经营模式成功案例分享
- 2025年桥梁维护养护合同
- 2025餐馆股份转让协议合同样本
- 永顺县应急知识培训课件学校
- 造口皮炎护理个案分享
- 海铁联运集装箱码头共享堆场堆存模板设计研究
- 农业新质生产力:助力乡村振兴
- 2025年下半年吉林省松原市前郭县事业单位招聘高校毕业生带编入伍19人历年自考难、易点模拟试卷(共500题附带答案详解)
- 青光眼中医护理查房
- 第二十章女性生殖内分泌疾病71课件
- 检修工安全培训
- 《外墙外保温工程技术标准》(JGJ 144-2019)
- 做账实操-工业企业的账务处理
- 中建梁场临时用电施工组织设计
- 体育与健康课件
评论
0/150
提交评论