外文翻译 - 基于V4L2嵌入式图像采集的实现_第1页
外文翻译 - 基于V4L2嵌入式图像采集的实现_第2页
外文翻译 - 基于V4L2嵌入式图像采集的实现_第3页
外文翻译 - 基于V4L2嵌入式图像采集的实现_第4页
外文翻译 - 基于V4L2嵌入式图像采集的实现_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

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

文档简介

外文原文TheImplementationofEmbeddedImageAcquisitionBasedonV4L2LUYinli,YUHongli,ZHANGPengpengPhysicalElectronics,DepartmentofElectricalEngineeringofUniversityofSouthChinaHengyang,PeoplesRepublicofC,AbstractInviewofthecurrentsituationofthelessembeddedLinuximageacquisitionapplicationbasedonV4L2(VideoforLinuxTwo),embeddedimageacquisitionsystembasedonV4L2isdesigned.S3C6410isadoptedashardwaredevelopmentplatformandLinuxassoftwareplatform.AfterloadingthedriverofCMOScameraOV9650andotherrelativedrivers,imageacquisitionapplicationsonthebasisofV4L2iscompiled,adoptingdoubleframebuffertoreduceCPUutilizationratetoaccomplishacquisitionandpreviewimage.Withthesizeof400480andtheframerateof15framespersecond,thepicturecollectedshowsclearlyandithasgoodquality.Theexperimentresultindicatesthatthesystemhasgoodscalability,anditoffersanewideaforembeddedhand-helddevices.Keywords-V4L2;OV9650;imageacquisition;S3C6410;doubleframebufferI.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:A.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,compileimageacquisitionapplicationsonthetoptogetimagedata,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)V4L2driverstructureV4Lhastwoshortages: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)openvideodevicev4l2_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:TherearetwoimportantsystemcallsforV4L2duringvideoacquisition:ioctl()andmmap().a)mainioctl()commandioctl()isapowerfulfunction.ItcancontroltheI/Ochannelsofequipment,settheformatofvideoandframe,andalsocaninquirycurrentdeviceproperties.MainioctlcommandsareshownastableI:Headerfilessuchasinclude/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:First,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.Forthenextstep,itishopedthatthepicturegatheredwillbeencodedandtransmittedtoPCtorealizevideosurveillance.ACKNOWLEDGEMENTWewishtothankProfessorHuangZhiweiofDepartmentofElectricalEngineeringatUniversityofSouthChinaforhisencouragementandsupportonthispaper.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,2010中文翻译基于V4L2嵌入式图像采集的实现摘要:考虑到基于V4L2(VideoforLinuxTwo)设计的Linux系统嵌入式图像采集应用程序较少这一现状,设计了基于V4L2的嵌入式图像采集应用程序。采用S3C6410作为硬件开发平台和Linux作为软件开发平台。在安装了CMOS摄像机OV650驱动以及其他相关驱动程序后,编译了基于V4L2的图像采集应用程序。为了减少CPU利用率,基于V4L2的图像采集应用程序采用双帧缓冲实现图像的采集和预览。在图片大小为400480和帧频为15帧/秒的条件下,采集到的图片很清晰而且质量很好。实验结果表明,该系统具有良好的可扩展性,而且它为嵌入式便携式设备提供了一个新的想法。关键字:V4L2,OV9650,图像采集,S3C6410,双帧缓冲器一、介绍视频图像处理技术广泛应用于电子技术和计算机技术。从照相机或其他图像采集设备上得到的图像以数字的形式转换,得到数字图像信息;然后,经过计算机的编码,过滤,增强,恢复,压缩,储存以及其他过程;最终呈现出视觉图像或其他结果。随着嵌入式技术的发展,现在的图像采集技术实现了从模拟到数字的转换。由于嵌入式图像采集技术具有优越的性能,受到了越来越多的人们的关注。对于图像处理系统来说,嵌入式图像微处理器是最好的选择,因为其具有高性能,高成本效益以及低功耗等优点。三星S3C6410具有ARM11核并且采用了64/32位内部总线架构。它还包括了许多强大的硬件加速器,比如视频处理,音频处理等等。一个完整的MFC(多格式编解码器)支持MPEG4/H.263/H.264的编码和解码以及VC1的解码,所以对于图像的处理是非常的方便。S3C6410被用作嵌入式硬件平台的核心,本文设计了基于V4L2的图像采集应用程序。把支持OV9650和V4L2的Linux操作系统内核和移植添加到硬件平台,最终图像被搜集并显示在液晶屏上。二、硬件系统结构整个图像采集系统主要包括CMOS摄像机OV9650,内核控制器S3C6410,液晶屏和其他外围设备。系统的硬件结构如图1:A处理器:三星S3C6410是基于ARM1176JZF-S核心,并且它的主要电源频率是533MHz/667MHz,包括媒体的SIMD(单指令多数据)处理。它适用于特殊的方法来使它适合视频处理。B.摄像机:这里使用的是OmniVision的OV9650摄像机。它集成了一个10位a/D转换器,对应于数据输出接口D0:9。通过内部DSP处理,输出图像数据格式可以10位原始RGB或8位RGB/YcbCr。使用的CAMIF支持ITU-BT601/656YCbCr8位模式。因此,OV9650的D9:2应该被链接到S3C6410中的CAMIF数据接口。C.外围设备:这部分主要包括液晶屏和触摸屏接口电路,JTAG调试电路,复位电路,电源电路,RS232串行接口电路等等。因为OV9650寄存器控制协议SCCB(一系列摄像机控制总线)可以兼容I2C,所以我们可以使用I2C作为后期平台模拟SCCB安装OV9650内部寄存器。三、软件设计有两个步骤来实现图像的采集:第一,在Linux内核底部加载相关驱动,第二,为了得到图像数据,在顶部编译图像采集应用程序,图像最终会显示在液晶屏上。A装载相关驱动在编译应用程序之前,应该先装载相关的驱动。因为,被采用的内核中包括驱动,所以仅仅添加相关的配置到内核中。1)内核配置在内核清单中,内核配置使用命令“makemenuconfig”:选择设备驱动程序多媒体设备Linux操作系统上视频软件,装载video4linux模块为视频设备提供编译接口;选择设备驱动程序多媒体设备三星相机接口驱动器外部相机OVTOV965x增加对CMOS图像传感器的支持到内核。保存配置并推出。2)内核图像的生成使用下面的指令:执行数据保护:读取配置文件并创造和配制相一致的相依树状结构来确定编译选项。制作图像:生成可以支持V4L2和OV9650的内核图像。在内核启动时,如果有如下的信息,表明OV9650驱动已成功加载:CAMOV9650initregstart.CAMOV9650initregend.在系统开始之后,它可以自动识别OV9650。系统调用可以用来获取设备信息来帮助应用程序的开发,CMOS图像传感器驱动提供的I/O操作界面可以实现相关的操作。B.图像采集应用程序V4L是由Linux提供的对于视频设备应用程序的一系列接口功能,图像数据可以使用API功能从视频设备上读出。1)V4L2驱动结构V4L有两个缺点:当驱动程序在被设计的时候,你不可以同时打开多个设备;而且,V4L2的API不能很好的支持有编译功能的设备,在这种情况下,BillDirks设计了一系列的API和数据结构,被叫做V4L2。和V4L相比,提高了可拓展性和灵活性,越来越多的视频设备包含在其管理之下。尽管V4L2是V4L的更新版本,但它们不兼容。V4L2被应用于Linux2.6内核驱动协议中。作为Linux系统中一个标准的视频捕捉装置:为了驱动的开发,V4L2采用了分层的方法来提供明确而始终如一的接口:应用程序在顶层,V4L2在中间层,而硬件装置实际在底层。V4L2有双重驱动体系结构。上面是videodev模块。当videodev被初始化,就指示自己为主号码为81的字符设备,并且它们自己的字符驱动数字功能被同时注册。较低的是V4L2驱动,事实上,videodev可以被叫做通过V4L2驱动数字功能的Videodev。在V4L2驱动被初始化后,包括V4L2驱动元函数,小数字和其他相关信息在内的结构都被传递给videodev,结果是,被手动操作的装置被注册到videodev。当V4L2被初始化时,首先要计算被处理的系统装置;然后,V4L2-装置被加到每一个设备中,并且指向V4L2-装置的指示器被传到V4L2-寄存器-装置中,这被称作为初始化设备而初始化V4L2-装置的功能。在被称作V4L2-寄存器-装置之前,信息的名字,类型,小数字和开放功能必须被

温馨提示

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

评论

0/150

提交评论