嵌入式摄像头抓图系统设计与实现-外文翻译_第1页
嵌入式摄像头抓图系统设计与实现-外文翻译_第2页
嵌入式摄像头抓图系统设计与实现-外文翻译_第3页
嵌入式摄像头抓图系统设计与实现-外文翻译_第4页
嵌入式摄像头抓图系统设计与实现-外文翻译_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

0外文原文AbstractInviewofthecurrentsituationofthelessembeddedLinuximageacquisitionapplicationbasedonV4L2(VideoforLinuxTwo),embeddedimageacquisitionsystembasedonV4L2isdesigned.S3C6410isadoptedashardwaredevelopmentplatformandLinuxassoftwareplatform.AfterloadingthedriverofCMOScameraOV9650andotherrelativedrivers,imageacquisitionApplicationsonthebasisofV4L2iscompiled,adoptingdoubleframebuffertoreduceCPUutilizationratetoaccomplishacquisitionandpreviewimage.Withthesizeof400480andtheframerateof15framespersecond,thepicturecollectedshowsclearlyandithasgoodquality.Theexperimentresultindicatesthatthesystemhasgoodscalability,anditoffersanewideaforembeddedhand-helddevices.KeywordsV4L2;OV9650;imageacquisition;S3C6410;doubleframebuffer1I.INTRODUCTIONThevideoimageprocessingtechnologyiswidelyusedinelectronictechnologyandcomputertechnology.Theimagefromacameraorotherimageacquisitionequipmentsistransformedmathematicallytogettheinformationofdigitalimage;then,itisencoded,filtered,enhanced,recovered,compressed,storedandotherprocessesconductedbythecomputer;visualimagesandotherresultsfinallywillbereceived.Withthedevelopmentofembeddedtechnology,thecurrentimageacquisitiontechnologyistransformedfromtheanaloguetothedigital.Amongthem,embeddedimageacquisitionattractsmoreandmorepeoplesattentionforitssuperiorperformance.Embeddedmicroprocessoristhebestchoicefortheimageprocessingsystembecauseofitshighperformance,cost-effective,andlowpower.SamsungS3C6410hasARM11coreandadopts64/32bitinternalbusarchitecture.Italsoincludesmanypowerfulhardwareacceleratorssuchasmotionvideoprocessing,audioprocessandsoon.AnintegratedMFC(MultiFormatcodec)supportsencodinganddecodingofMPEG4/H.263/H.264anddecodingofVC1,soitisveryconvenientforimageprocessing.S3C6410isutilizedasthecoreoftheembeddedhardwareplatform,thepaperdesignsaimagecollectionapplicationsonbaseofV4L2.AfteraddingsupportforOV9650andV4L2tothekernelandtransplantingLinuxoperatingsystemtothehardwareplatform,imageacquisitionapplications,usingdoubleframebuffertoreducepowerconsumption,isdevisedonthebasisofV4L2,ultimately,picturewillbegatheredandshowedontheLCD.II.HARDWARESYSTEMSTRUCTUREThewholeimageacquisitionsystemmainlyincludesCMOScameraOV9650,corecontrollerS3C6410,LCDandothersperipherals.Thesystemhardwarestructureisshowedasfigure1:2HOSTPCJTAGRS232POWERLCDFLASHSDRAMCaminterfaceOV9650S3C6410microprocessorFigure1GeneralhandwareplatformA.Processor:SamsungS3C6410isbasedonARM1176JZF-Score,anditsmainfrequencyis533MHz/667MHz,includingSIMD(singleinstructionmultipledata)formediaprocessing.Itappliesspecialwaystomakeitsuitableforvideoprocessing.B.Camera:OmniVisionsOV9650isusedhere.Itincorporatesa10bitA/Dconverter,correspondingtodataoutputinterfaceD0:9.Theoutputimagedataformatcanbe10bitrawRGBor8bitRGB/YCbCrthroughinternalDSPprocessing.TheCAMIFusedsupportsITU-BT601/656YCbCr8bitmode.Asaresult,D9:2ofOV9650shouldbeconnectedtothedatainterfaceofCAMIFforS3C6410.C.Peripherals:ThispartmainlyincludesLCDandtouchscreeninterfacecircuit,JTAGdebuggingcircuit,resetcircuit,thepowersupplycircuit,RS232serialinterfacecircuitandsoon.BecauseOV9650registerscontrolprotocolSCCB(serialcameracontrolbus)canbecompatiblewithI2C,soweuseI2Cofback-endplatformtosimulateSCCBtoconfiguretheOV9650internalregisters.III.SOFTWAREDESIGNTherearetwostepstoachievetherealizationofimagecollection:firstly,loadtherelatingdrivertoLinuxkernelonthebottom;secondly,compileimageacquisition3applicationsonthetoptogetimagedata,whichwillbeshowedonLCDfinally.A.LoadtherelatingDriverBeforecompilingtheapplicationsprocedure,driversrelatedshouldbeloadedatfirst.Becausethekerneladoptedincludesthedrivers,sojustaddcorrelativeconfigurationtothekernel.1)kernelconfiguration:Inthedirectoryofkernel,usethecommandmakemenuconfigforkernelconfiguration:chooseDeviceDriversMultimediadeviceVideoforlinux,loadvideo4linuxmoduletoprovideprogramminginterfaceforvideodevice;chooseDeviceDriversMultimediadevicesVideocaptureadaptersSamsungCameraInterfacedriversExternalCameraOVTOV965x,addthesupportofCMOSimagesensortothekernel.Savetheconfigurationandquit.2)generatekernelimageUsethecommandsbelow:makedep:readtheconfigurationfileandcreatdependencytreecorrespondingtotheconfigurationtodeterminecompileoptions;makezImage:generatethekernelimagethatcansupportV4L2andOV9650.Whenthekernelstarts,ifthereisthesameinformationasfollows,itindicatesthatthedriverofOV9650hasbeenloadedsuccessfully:CAMOV9650initregstart.CAMOV9650initregend.Afterthesystemstarts,itcanautomaticallyidentifyOV9650.Systemcallscanbeutilizedtoobtainequipmentinformationtofacilitateapplicationdevelopment,theI/OoperationinterfacefunctionprovidedbyCMOSimagesensordrivercanrealizetherelevantoperation.B.ImageAcquisitionApplicationsV4LisarangeofinterfacefunctionsprovidedbyLinuxforvideodevicesapplications,theimagedatacanbereadoutfromvideoequipmentbyusingAPIfunctions.1)V4L2driverstructure4V4Lhastwoshortages:whendrivingprogramisbeingdesigned,youcannotopenmultipleequipmentatthesametime;furthermore,V4LAPIcannotwellsupportequipmentswithencodingability.Underthiscircumstance,BillDirksredesignedasetofAPIsanddatastructure,calledV4L2.ComparedtoV4L,theextensibilityandflexibilityareimproved,morevideodevicesareincludedinitsmanagement.AlthoughV4L2istheupdatedversionofV4L,theyarenotcompatible.V4L2isappliedasLinux2.6kerneldriveragreement.AsaspecificationsofvideocapturedevicedriverforLinux,V4L2adoptsalayeredapproachtoofferclearandconsistentinterfacefordriverdevelopment:theapplicationisatthetop,V4L2inthemiddlelayer,whiletheactualhardwaredeviceonthebottom.V4L2hastwo-tierdriverarchitecture.Theupperisvideodevmodule.Whenthevideodevhasbeeninitialized,itregistersitselfasacharacterdeviceofmajornumber81,andtheirowncharactersdrivermemberfunctionsareregisteredsimultaneously.ThelowerisV4L2driver,videodevclientinfact,whichcanbecalledbyVideodevthroughV4L2drivermemberfunctions.AfterV4L2driverisinitialized,thestructureincludingV4L2drivermemberfunctions,minornumberandotherrelatedinformationispassedtovideodev,consequently,thedevicetobehandledisregisteredtovideodev.WhenV4L2driverisbeinginitialized,firstofall,systemdevicetobeprocessedisenumerated;then,thestructurev4l2_deviceisaddedforeachdevice,andthepointerdirectingtothestructurev4l2_deviceispassedtov4l2_register_device(),whichcallsinitializationfunctionsofv4l2_devicetoinitializedevices.Beforecallingv4l2_register_device(),theinformationofname,type,minornumberandopenfunctionmustbeaddedtodriver.Whenadriveristouchedoffbyapplications,thecontrolwillfirstlybedeliveredtothefunctionsofvideodev,videodevhasresponsibilitytotransformfileornodestructurepointerpassedbyapplicationstoV4L2structurepointer,andcallsprocessingfunctionsofV4L2driver.2)ImageacquisitionbasedonV4L2ThemainstepsofvideocaptureofV4L2areasfollows:a)openvideodevice5v4l2_fd=open(V4L2_DEV_NODE,O_RDWR);open/dev/video0;fb_fd=open(FB_DEV_NODE,O_RDWR);openframbuffer;b)deviceinitializationQuerythedevicepropertiesandgetfunctionsupportedbyVIDIOC_QUERYCAP;setpictureformatusingVIDIOC_S_FMT;allocatememorybufferinthekernelspaceanduserspacerespectivelythroughVIDIOC_REQBUFSandmalloc(),andfinallyutilizemmap()formemorymapping.c)imageacquisitionanddisplayStartandstopacquisitionbyVIDIOC_STREAMONandVIDIOC_STREAMOFF.Therearetwowaysforvideoacquisition:memorymappingandreadingdatadirectlyfromdevice.Imagecollectionbydoublecachethroughmmap()isusedhere.Compilepreviewfunctionv4l2_show_on_fb(v4l2_fd,fbmem,preview_frames)topreviewthepictures.d)closevideodevice3)Closethedevicethroughclose().TheflowchartofimageacquisitionbasedonV4L2isasfigure2:6StartOpenvideodeviceopenframbufferGetdeviceinformationGetpicturequalityApplybuffersandmapmemoryVideoimageacquisitionPreviewonLCDImageacquisitionisstoppedClosedevicecloseNYFigure2flowchartofimageacquisitionTherearetwoimportantsystemcallsforV4L2duringvideoacquisition:ioctl()andmmap().a)mainioctl()commandioctl()isapowerfulfunction.ItcancontroltheI/Ochannelsofequipment,settheformatofvideoandframe,andalsocaninquirycurrentdeviceproperties.MainioctlcommandsareshownastableI:7Table1MAINIOCTLCOMMANDSIoctlCommandFunctionDiscriptionVIDIOC_CROPCAPVideoinformationogcuttingandscalingcapabilitiesVIDIOC_G_CROPVIDIOC_S_CROPReadorsettherectangularareacurrentlycroppingVIDIOC_G_FMTVIDIOC_S_FMTVIDIOC_TRY_FMTReadorsetdataformatandformatVIDIOC_G_STDVIDIOC_S_STDInquiryorchoosevideostandardscurrentlyinputVIDIOC_QBUFVIDIOC_DQBUFReaddatafrombuffersorputdatabacktobuffersequenceVIDIOC_QUERYCAPQuerydeviceattributeHeaderfilessuchasinclude/linux/videodev2.horvideodev.hcanbeaddedtothekerneltoachievetheabovefunctioncalls.b)memorymappingmmap()Therearetwowaystocapturethevideoimage:oneisread()forreadingdirectly,andtheotherismmap()formemorymapping.Mmap()givesachanceforsharingmemorybetweenprocessesthroughmappingacommonfile.Afterageneralfileismappedtotheaddressspaceofprocess,thefilecanbeaccessedbyprocessesasordinarymemory,thatis,thememorycanbereadandwrotedirectly,andthereisnoneedtocallread()andwrite(),itcanaccelerateI/Oaccess.Inthethirdstepofimageacquisitionabove,datacopyisreplacedbymultiplecacheforimagecollectionthroughmmap()toimproveefficiency.Twoimagebuffersarecreatedinthekernelspace,whenapplicationsneedimages,datawillbesharedbymappingthekernelbuffertouserspacethroughmmap().Theprocessofvideoimagecollectionusingdoubleframebufferisasfollows:8First,requestimagebufferthroughVIDIOC_REQBUFS;second,callmmap()twicetocreatecorrespondingrelationbetweenuserspaceandkernelspacebuffer;third,addthebuffertocollectionsequencebesidedriverbyVIDIOC_QBUF;fourth,starttogatherimageandplacetheminthebufferzoneusingVIDIOC_STREAMON;fifth,VIDIOC_STREAMOFFiscalledtostopcollectingimage.Atthispoint,thedriverwillautomaticallyremoveallthebuffersfromimageacquisitionsequence,andclearallthememorymappingsbymunmap().Note:beforereadingbufferzone,VIDIOC_DQBUGshouldbecalledatfirsttonoticethatthebufferisunavailable,oritwillleadtoinconsistenceofrelatingimages.IV.RESULTANDPROSPECTThefollowingfigure3showsthehardwareplatformandtheresultofexperiment.Thecollectingpicture,whosesizeis400480,displayedontheLCDclearly.BasedonLinuxplatform,theimageiscollectedbyCMOScameraandpreviewedsuccessfullyusingimageacquisitionapplicationsonthebaseofV4L2.Duringtheoperationinactual,thepicturesdisplaywellandhavegoodquality.Theadvantagesofthesystemaregoodscalabilityandextensiveuse,andsomereferencevalueissuppliedforrelevantareasofvideoimageacquisition.Figure3ExperimentresultForthenextstep,itishopedthatthepicturegatheredwillbeencodedandtransmittedtoPCtorealizevideosurveillance.9ACKNOWLEDGEMENTWewishtothankProfessorHuangZhiweiofDepartmentofElectricalEngineeringatUniversityofSouthChinaforhisencouragementandsupportonthispaper.Besides,wealsoappreciateseniorsatthelaboratoryfortheirsuggestionandproofreadingspellingforthepaper.REFERENCE1SongLili.ImageCaptureandPretreatmentDeviceDesignBasedonEmbeddedSystem.JournalofHarbinUniversityofScienceandTechnology,2010,15(3):23-262SamSungElectronics.S3C6410microprocessorusersmanual.www.S,20093OminiVisionTechnologiesInc.OV9650ColorCMOSSXGA(1.3MegaPixel)CamerachipTMImplementationG,20044DirksB.VideoforLinuxTwoAPISpecificationDraft0.24./spec/book1.htm,20085LiuYakun,ChenXiaodong.ThestudyofvideoacquisitionandcompressioncodecsystembasedonDaVinci:2010InternationalConferenceonInformationNetworkingandAutomation,2010(2)V2-317V2-3216LiuYonggui,FanLimin,HuFuqiao.StudyBasedonImplementMethodofVideoCaptureSystem.ModernElectronicTechique.2008(7):61-647ZhengJiehang.TheDesignofNetworkVideoMonitoringBasedonARM.MsDThesis.Wuhan:WuhanUniversityofTechnology,201010中文翻译摘要鉴于少数Linux嵌入式的图像采集的应用程序是基于V4L2(video4forlinuxtwo)的,由于基于V4L2的嵌入式图像采集系统目前的状况是成熟的。S3C6410被用作硬件开发平台然而Linux作为软件平台。加载CMOS摄像头OV9650和其他相关的驱动程序,图像采集的驱动程序是在V4L2的基础上,编译应用程序是采用双帧缓冲,以减少CPU使用率来完成采集图像和预览图像。大小为400480,帧速率为每秒15帧,所收集的图像清楚地表明这样的系统具有良好的质量。实验结果表明,该系统具有良好的可扩展性,并提供对嵌入式手持设备的新思路。关键词V4L2;OV9650;图像采集;S3C6410;双帧缓冲11引言视频图像处理技术被广泛应用在电子技术和计算机技术。从照相机和其他图像采集设备的图像转换到数据上,以获得图像数据的信息,然后,进行编码,过滤,增强,恢复,压缩,存储和通过计算机进行的其他过程,视频图像和其他结果最终会保存到计算机中。随着嵌入式技术的发展,当前图像采集技术转化从theanalogue到数据信息。其中,嵌入式图像采集因为其优越的性能吸引了越来越多的人的关注。嵌入式微处理器因为它的高性能,低成本,和低功耗成为了用于图像处理系统的最佳选择。三星S3C6410有ARM11内核,并采用64位/32位的内部总线架构。还包含了很多强大的硬件加速器,如运动视频处理,音频处理等。一个集成的MFC(多格式编解码器)支持的编码和MPEG4/H.263/H.264和VC1的解码解码,所以它是非常方便的图像处理内核。S3C6410作为嵌入式硬件平台,本文在V4L2的核心上增加对OV9650和V4L2支持的内核和移植Linux操作系统硬件平台的基础设计了图像采集应用。这里的图像采集应用使用双帧缓冲,以降低功耗,在设计V4L2的基础上,最终,图片将被收集并显示在LCD上。硬件系统结构整个图像采集系统主要包括CMOS摄像头OV9650,核心控制器S3C6410,液晶显示器和其他外设。该系统的硬件结构表现为图1:JTAGRS232POWERLCDFLASHSDRAM接口OV9650S3C6410微处理器主机图1硬件结构A:处理器:三星S3C6410是基于ARM1176JZF-S内核,其主要频率为533MHz/667MHz,包括SIMD(单指令多数据)的媒体处理。它使用特殊的方法以此12适用于视频处理。B.摄像头:OmniVision的OV9650作为本设计的摄像头。它集成了一个10位A/D转换器,相应的数据输出接口D0:9。输出图像数据格式可以通过内部DSP处理为10位原始RGB或8位RGB/YCbCr图像。所使用的CAMIF支持ITU-BT六百五十六分之六百一的YCbCr8位模式。因此,D9:2OV9650的应连接到CAMIF的S3C6410的数据接口。C.外设:该部分主要包括LCD和触摸屏接口电路,JTAG调试电路,复位电路,电源电路,RS232串行接口电路等。因为OV9650寄存器控制协议SCCB(串行摄像机控制总线),可与I2C兼容的,所以我们使用的后端平台的I2C模拟SCCB配置OV9650内部寄存器。软件设计有两个步骤实现实现图像采集:首先,加载相关的驱动程序,使用底部Linux内核,其次,编译顶部图像采集应用程序以获取图像数据,这将在LCD上终于得以呈现。A:加载有关的驱动程序在编译应用程序之前,相关的驱动程序应该首先被加载。由于所采用的内核包含了驱动程序,所以相关的配置只需要添加到内核中。1)内核配置:在内核中的目录,使用命令“makemenuconfig的”内核配置:选择设备驱动程序多媒体设备视频为linux,负载的Video4Linux模块提供的编程接口,用于视频设备;选择设备驱动程序多媒体设备视频捕获适配器三星摄像头接口驱动程序外部摄像机OVTOV965x,CMOS图像传感器的支持添加到内核。保存配置并退出。2)生成内核映像:使用下面的命令:makedep的:读取配置文件,共创依赖关系树相应的配置,以确定编译选项,zImage:产生可以支持V4L2和OV9650的内核映像。当内核启动时,如果如下所示信息,则表明OV9650的驱动程序已经加载成功:CAMOV9650initregstart.CAMOV9650initregend.系统启动后,它可以自动识别OV9650.,系统调用来获取设备信息,方便应用开发,提供CMOS图像传感器的驱动程序可以实现相关操作的I/O操作接口函数。B:图像采集应用部分V4L是一系列被Linux提供了视频设备的应用中,图像数据可从视频设备中读出通过使用API函数的接口功能。1)V4L2驱动结构V4L有两个不足:当驱动程序被设计的,你不能同时打开多个设备,此外,V4L的API无法很好地支持设备与编码能力。在这种情况下,BillDirks重新设计了一套API13和数据结构,称为V4L2.与V4L相比,可扩展性和灵活性得到改善,包含了更多的视频设备。虽然V4L2是V4L的升级版,它们不可比较的,V4L2被作为Linux2.6内核驱动协议应用。作为一个规范的Linux的视频采集设备的驱动程序,V4L2采用分层的方法,以提供清晰,一致的接口驱动程序开发:应用程序位于顶部,V4L2在中间层中,而在底部的实际硬件设备。V4L2有两层驱动程序体系结构。上层是videodev模块。当videodev已被初始化,它本身注册为的主设备号81字符设备,和自己的字符驱动程序的成员函数被同时注册。下层是V4L2驱动,事实上videodev客户端,可以通过V4L2驱动构件的功能被称为Videodev。之后V4L2驱动初始化,包括V4L2驱动的成员函数,次设备号等相关信息的结构被传递给videodev,因此,要处理的设备注册到videodev。当V4L2驱动被初始化,首先,系统设备要处理的枚举,然后,该结构v4l2_device为每个设备,并将该指针指向所述结构v4l2_device传递给v4l2_register_device(),它调用v4l2_device的初始化函数来初始化设备。在调用v4l2_register_device()的名称,类型,次设备号和开放功能的信息必须被添加到驱动程序。当一个驱动程序由应用程序触发,控制将首先交付给videodev的功能,videodev有责任转换文件或应用程序到V4L2的结构指针传递节点结构的指针,并调用V4L2驱动的处理功能。2)基于V4L2的图像采集基于V4L2视频采集的主要步骤如下:a)打开视频设备v4l2_fd=open(V4L2_DEV_NODE,O_RDWR);打开/dev/video0;fb_fd=open(FB_DEV_NODE,O_RDWR);打开帧缓冲;b)设备初始化查询设备的属性和功能得到支持VIDIOC_QUERYCAP;使用VIDIOC_S_FMT设置图片格式;在内核空间和用户空间分别通过VIDIOC_REQBUFS和malloc()分配内存缓冲区,最后利用mmap()的内存映射。c)图像采集和显示启动和VIDIOC_STREAMON和VIDIOC_STREAMOFF停止采集。有两种方法用于视频采集:内存映射,直接从设备中读取数据。通过mmap的双缓存图像采集()被用在这里。编辑预览功能v4l2_show_on_fb(v4l2_fd,fbmem,preview_frames)来预览图片。d)关闭设备3)通过close()关闭装置4)图像采集的基于V4L2的流程图如图2:14开始打开视频设备获取设备信息设置图片格式使用缓冲区和内存映射获取图像信息显示采集停止关闭设备停止NY图2采集图像流程图还有的V4L2在视频采集两个重要的系统调用:ioctl()和mmap()。A)主要的ioctl()命令操作Ioctl()是一个强大的操作函数。它可以控制设备的I/O通道,设置视频和帧的格式,并且还可以查询当前设备的属性。主要的ioctl命令如表1:15表1主要的ioctl命令I/O操作功能描述VIDIOC_CROPCAP查询驱动的修建能力VIDIOC_G_CROPVIDIOC_S_CROP读取视频信号的边框设置视频信号的边框VIDIOC_G_FMTVIDIOC_S_FMTVIDIOC_TRY_FMT设置或者查看驱动格式VIDIOC_G_STDVIDIOC_S_STD查询或者设置标准输入VIDIOC_QBUFVIDIOC_DQBUF缓存中读取数据或者将缓存区放入队列VIDIOC_QUERYCAP查询设备属性头文件如include/linux/vid

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论