




已阅读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 0 0 b if z z 0 yuyv 4 成都理工大学 2013 届本科毕业设计 论文 32 displaybuffer g 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 对应屏幕的宽度和高度 对扫描显示换行进行控制 从而显示出完整的图像 算法如下 for i 0 i hight i for j 0 j wide j screenbuf Image Image 1 vinfo xres wide 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 Stones Beginning Linux Programming M 北京 人民邮电出版社 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 12 Yang Xiaofei Deng Jian Liao Junqing Function development of USB host in embedded system J Huazhong 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 13 Liu Junliang Pan Gang Li Ping Embedded Linux graphic terminal designb ased on ARM J 2006 Chinese Control Conference Proceedings CCC 2006 1921 1925 14 黄睿邦 汤采江 李文亮 Linux 下基于 Video4Linux 的 USB 摄像头视频采集 实现 J 现代计算机开发案例 2009 309 182 184 15 王俊 基于嵌入式 Linux 视频监控传输系统的设计与实现 J OL Digital Technology and Application 2013 1 成都理工大学 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 s n 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 pointer 1 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 video height int x unsigned char ptr line buffer for x 0 x video width x int r g b int y u v if z y yuyv 0 8 else y yuyv 2 8 g y 88 u 183 v 8 b y 454 u 8 ptr r 255 255 r 255 255 g 255 255 b 0 0 b if z z 0 yuyv 4 displaybuffer g displaybuffer r row pointer 0 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 0 x x bytes n file length printf bytes per line is d height is d width is d n 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 d n v4l2 reqbuf count mmap the buffer required buffers calloc v4l2 reqbuf count sizeof VideoBuffer for num bufs 0 num bufs v4l2 reqbuf count num bufs memset v4l2 buf type V4L2 BUF TYPE VIDEO CAPTURE v4l2 buf memory V4L2 MEMORY MMAP v4l2 buf index num bufs if 1 ioctl camerafd VIDIOC QUERYBUF exit EXIT FAILURE buffers num bufs start mmap NULL v4l2 buf length PROT READ PROT WRITE MAP SHARED camerafd v4l2 buf m offset if MAP FAILED buffers num bufs start printf mmap d num bufs exit EXIT FAILURE buffers num bufs length v4l2 buf length put the buffers to the waiting queue of the camera memset v4l2 buf type V4L2 BUF TYPE VIDEO CAPTURE v4l2 buf memory V4L2 MEMORY MMAP for num bufs 0 num bufs v4l2 reqbuf count num bufs v4l2 buf index num bufs ret ioctl camerafd VIDIOC QBUF 成都理工大学 2013 届本科毕业设计 论文 42 if ret perror ioctl VIDIOC QBUF close camerafd exit EXIT FAILURE return 0 int ready for capture void int ret init buffer for jpeg src rgb unsigned char malloc video width video height 2 1 dest rgb unsigned char malloc video width video height 2 1 displaybuffer start unsigned char malloc video width video height 2 1 1 10 1 for length of size of jpg file 10 for characters for size of jpeg file dest jpeg send buffer start 4 assert displaybuffer start assert src rgb assert dest rgb printf s d address of src rgb is 0 x x n FUNCTION LINE unsigned int src jpeg printf s d address of displaybuffer start is 0 x x n FUNCTION LINE unsigned int send buffer start printf s d address of dest rgb is 0 x x n FUNCTION LINE unsigned int dest jpeg v4l2 type V4L2 BUF TYPE VIDEO CAPTURE ret ioctl camerafd VIDIOC STREAMON if ret perror ioctl VIDIOC STREAMON close camerafd exit EXIT FAILURE return 0 start to capture printf start to capture n int ret FD ZERO FD SET camerafd tv tv sec 2 tv tv usec 0 ret select camerafd 1 if ret fbfd open PATH O RDWR if fb fbfd err exit fb open printf The framebuffer device was opened sucessfully n return fb static FB g
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 【正版授权】 ISO 24427:2025 EN Radiological protection - Medical proton accelerators - Requirements and recommendations for shielding design and evaluation
- 稀土抛光粉工三级安全教育(车间级)考核试卷及答案
- 油墨加工工综合考核试卷及答案
- 铝电解槽槽底修复技术工艺考核试卷及答案
- 影视服装员新员工考核试卷及答案
- 工艺美术品公司合伙协议书
- 应用化学招聘面试题库及答案
- 银行资管考试题及答案大全
- 银行职工测试题库及答案
- 银行招聘试题及答案
- 2024年度海南省高校教师资格证之高等教育学题库与答案
- 9.4静电的防止与利用“教学评”一体化教学设计
- ASTM-D3359-(附著力测试标准)-中文版
- 2024年铝材购销的合同范本
- T-CACM 1560.1-2023 中医养生保健服务(非医疗)技术操作规范推拿
- 护理美学-第三章 护士审美修养
- 篮球教学活动设计方案
- 大学生生涯发展展示 (修改版)
- DB32T4062-2021城市轨道交通工程质量验收统一标准
- (正式版)JBT 14897-2024 起重磁铁安全技术规范
- 西方节日-英文介绍
评论
0/150
提交评论