matlab相机定标工具箱程序的算法原理上课讲义_第1页
matlab相机定标工具箱程序的算法原理上课讲义_第2页
matlab相机定标工具箱程序的算法原理上课讲义_第3页
matlab相机定标工具箱程序的算法原理上课讲义_第4页
matlab相机定标工具箱程序的算法原理上课讲义_第5页
已阅读5页,还剩10页未读 继续免费阅读

下载本文档

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

文档简介

1、Good is good, but better carries it.精益求精,善益求善。matlab相机定标工具箱程序的算法原理CameraCalibrationToolboxforMatlabDescriptionofthecalibrationparametersAftercalibration,thelistofparametersmaybestoredinthematabfileCalib_ResultsbyclickingonSave.Thelistofvariablesmaybeseparatedintotwocategories:Intrinsicparametersande

2、xtrinsicparameters.Intrinsicparameters(cameramodel):TheinternalcameramodelisverysimilartothatusedbyHYPERLINKhttp:/www.ee.oulu.fi/jth/Heikkil伯aandHYPERLINKhttp:/www.ee.oulu.fi/olli/SilvenattheHYPERLINKhttp:/www.ee.oulu.fi/UniversityofOuluinFinland.VisittheironlineHYPERLINKhttp:/www.ee.oulu.fi/jth/cal

3、ibr/Calibration.htmlcalibrationpage,andtheirHYPERLINKhttp:/www.ee.oulu.fi/jth/doc/publicationpage.WespecificallyrecommendtheirCVPR97paper:HYPERLINK/bouguetj/calib_doc/papers/heikkila97.pdfAFour-stepCameraCalibrationProcedurewithImplicitImageCorrection.Thelistofinternalparameters:Focallength:Thefocal

4、lengthinpixelsisstoredinthe2x1vectorfc.Principalpoint:Theprincipalpointcoordinatesarestoredinthe2x1vectorcc.Skewcoefficient:Theskewcoefficientdefiningtheanglebetweenthexandypixelaxesisstoredinthescalaralpha_c.Distortions:Theimagedistortioncoefficients(radialandtangentialdistortions)arestoredinthe5x1

5、vectorkc四个内参,包括焦距fc,原点坐标cc,相机坐标系中x和y轴夹角alpha_c(接近90),几何畸变系数kc.Definitionoftheintrinsicparameters:LetPbeapointinspaceofcoordinatevectorXXc=Xc;Yc;Zcinthecamerareferenceframe.Letusprojectnowthatpointontheimageplaneaccordingtotheintrinsicparameters(fc,cc,alpha_c,kc).Letxnbethenormalized(pinhole)imagepro

6、jection:Letr2=x2+y2.Afterincludinglensdistortion,thenewnormalizedpointcoordinatexdisdefinedasfollows:wheredxisthetangentialdistortionvector:Matlab中计算几何畸变还考虑了切向畸变Therefore,the5-vectorkccontainsbothradialandtangentialdistortioncoefficients(observethatthecoefficientof6thorderradialdistortiontermisthefi

7、fthentryofthevectorkc).ItisworthnoticingthatthisdistortionmodelwasfirstintroducedbyBrownin1966andcalledPlumbBobmodel(radialpolynomial+thinprism).Thetangentialdistortionisduetodecentering,orimperfectcenteringofthelenscomponentsandothermanufacturingdefectsinacompoundlens.Formoredetails,refertoBrownsor

8、iginalpublicationslistedintheHYPERLINK/bouguetj/calib_doc/htmls/ref.htmlreferencepage.Oncedistortionisapplied,thefinalpixelcoordinatesx_pixel=xp;ypoftheprojectionofPontheimageplaneis:Therefore,thepixelcoordinatevectorx_pixelandthenormalized(distorted)coordinatevectorxdarerelatedtoeachotherthroughthe

9、linearequation:whereKKisknownasthecameramatrix,anddefinedasfollows:对应于书上的线性映射矩阵AFc(1)和fc(2)分别对应于矩阵A中的f/k和f/l,即转化为按照x和y方向上的像素尺寸为单位Inmatlab,thismatrixisstoredinthevariableKKaftercalibration.Observethatfc(1)andfc(2)arethefocaldistance(auniquevalueinmm)expressedinunitsofhorizontalandverticalpixels.Bothc

10、omponentsofthevectorfcareusuallyverysimilar.Theratiofc(2)/fc(1),oftencalledaspectratio,isdifferentfrom1ifthepixelintheCCDarrayarenotsquare.Therefore,thecameramodelnaturallyhandlesnon-squarepixels.Inaddition,thecoefficientalpha_cencodestheanglebetweenthexandysensoraxes.Consequently,pixelsareevenallow

11、edtobenon-rectangular.Someauthorsrefertothattypeofmodelasaffinedistortionmodel.Inadditiontocomputingestimatesfortheintrinsicparametersfc,cc,kcandalpha_c,thetoolboxalsoreturnsestimatesoftheuncertaintiesonthoseparameters.Thematlabvariablescontainingthoseuncertaintiesarefc_error,cc_error,kc_error,alpha

12、_c_error.Forinformation,thosevectorsareapproximatelythreetimesthestandarddeviationsoftheerrorsofestimationFc_error,cc_error,kc_error,alpha_c_error这四个变量记录四个内参的不确定度,大小设定为三倍标准差.Hereisanexampleofoutputofthetoolboxafteroptimization:Inthiscasefc=657.30254;657.74391andfc_error=0.28487;0.28937,cc=302.71656;

13、242.33386,cc_error=0.59115;0.55710,.ImportantConvention:Pixelcoordinatesaredefinedsuchthat0;0isthecenteroftheupperleftpixel注意:图像左上角默认为原点0;0左下角为0;ny-1右上角为nx-1;0右下角为nx-1;ny-1oftheimage.Asaresult,nx-1;0iscenteroftheupperrightcornerpixel,0;ny-1isthecenterofthelowerleftcornerpixelandnx-1;ny-1isthecentero

14、fthelowerrightcornerpixelwherenxandnyarethewidthandheightoftheimage(fortheimagesofthefirstexample,nx=640andny=480).Onematlabfunctionprovidedinthetoolboxcomputesthatdirectpixelprojectionmap.Thisfunctionisproject_points2.m.Thisfunctiontakesinthe3Dcoordinatesofasetofpointsinspace(inworldreferenceframeo

15、rcamerareferenceframe)andtheintrinsiccameraparameters(fc,cc,kc,alpha_c),andreturnsthepixelprojectionsofthepointsontheimageplane.Seetheinformationgiveninthefunction函数project_points2.m将相机坐标系下的三维点阵按照内参转化成图像平面上的二位点阵.Theinversemapping:Theinverseproblemofcomputingthenormalizedimageprojectionvectorxnfromth

16、epixelcoordinatex_pixelisveryusefulinmostmachinevisionapplications.However,becauseofthehighdegreedistortionmodel,thereexistsnogeneralalgebraicexpressionforthisinversemap(alsocallednormalization).Inthetoolboxhowever,anumericalimplementationofinversemappingisprovidedintheformofafunction:normalize.m.He

17、reisthewaythefunctionshouldbecalled:xn=normalize(x_pixel,fc,cc,kc,alpha_c).Inthatsyntax,x_pixelandxnmayconsistofmorethanonepointcoordinates.Foranexampleofcall,seethematlabfunctioncompute_extrinsic_init.m.Reducedcameramodels:Currentlymanufacturedcamerasdonotalwaysjustifythisverygeneralopticalmodel.Fo

18、rexample,itnowcustomarytoassumerectangularpixels,andthusassumezeroskew(alpha_c=0).It一般情况下,相机坐标系中的坐标轴正交,alpha_c就可以默认为0;在非广角镜头中,一般径向畸变模型到4阶就足够了(好的镜头2阶就够了),而且切向畸变可以忽略isinfactadefaultsettingofthetoolbox(theskewcoefficientnotbeingestimated).Furthermore,theverygeneric(6thorderradial+tangential)distortionm

19、odelisoftennotconsideredcompletely.Forstandardfieldofviews(nonwide-anglecameras),itisoftennotnecessary(andnotrecommended)topushtheradialcomponentofdistortionmodelbeyondthe4thorder(i.e.keepingkc(5)=0).Thisisalsoadefaultsettingofthetoolbox.Inaddition,thetangentialcomponentofdistortioncanoftenbediscard

20、ed(justifiedbythefactthatmostlensescurrentlymanufactureddonothaveimperfectionincentering).The4thordersymmetricradialdistortionwithnotangentialcomponent(thelastthreecomponentofkcaresettozero)isactuallythedistortionmodelusedbyHYPERLINK/bouguetj/calib_doc/htmls/ref.htmlZhang.Anotherverycommondistortion

21、modelforgoodopticalsystemsornarrowfieldofviewlensesisthesecondordersymmetricradialdistortionmodel.Inthatmodel,onlythefirstcomponentofthevectorkcisestimated,whiletheotherfouraresettozero.Thismodelisalsocommonlyusedwhenafewimagesareusedforcalibration(toolittledatatoestimateamorecomplexmodel).Asidefrom

22、distortionsandskew,othermodelreductionsarepossible.Forexample,whenonlyafewimagesareusedforcalibration(e.g.one,twoorthreeimages)theprincipalpointccisoftenverydifficulttoestimatereliably.Itisknowntobeoneofthemostdifficultpartofthenativeperspectiveprojectionmodeltoestimate(ignoringlensdistortions).Ifth

23、isisthecase,itissometimesbetter(andrecommended)tosettheprincipalpointatthecenteroftheimage(cc=(nx-1)/2;(ny-1)/2)andnotestimateitfurther.Finally,infewrareinstances,itmaybenecessarytorejecttheaspectratiofc(2)/fc(1)fromtheestimation.Althoughthisfinalmodelreductionstepispossiblewiththetoolbox,itisgenera

24、llynotrecommendedastheaspectratioisofteneasytoestimateveryreliably.Formoreinformationonhowtoperformmodelselectionwiththetoolbox,visittheHYPERLINK/bouguetj/calib_doc/htmls/example.htmlpagedescribingthefirstcalibrationexample.CorrespondencewithHeikkilnotation:IntheoriginalHYPERLINK/bouguetj/calib_doc/

25、papers/heikkila97.pdfHeikkilpaper,theinternalparametersappearwithslightlydifferentnames.Thefollowingtablegivesthecorrespondencebetweenthetwonotationschemes:OurnotationHeikkilnotationfc(1)f.Du.sufc(2)f.Dvcc(1)u0cc(2)v0alpha_c0kc(1)f3.k1kc(2)f5.k2kc(3)f2.p1kc(4)f2.p2kc(5)0AfewcommentsonHeikkilmodel:Sk

26、ewisnotestimated(alpha_c=0).Itmaynotbeaproblemasmostcamerascurrentlymanufactureddonothavecenteringimperfections.Theradialcomponentofthedistortionmodelisonlyuptothe4thorder.Thisissufficientformostcases.Thefourvariables(f,Du,Dv,su)replacingthe2x1focalvectorfcareingeneralimpossibletoestimateseparately.

27、Itisonlypossibleiftwoofthosevariablesareknown(forexamplethemetricfocalvaluefandthescalefactorsu).SeeHYPERLINK/bouguetj/calib_doc/papers/heikkila97.pdfHeikkilpaperformoreinformation.CorrespondencewithRegWillsonsnotation:InhisoriginalHYPERLINK/afs/user/rgw/www/TsaiCode.htmlimplementationoftheTsaicamer

28、acalibrationalgorithm,HYPERLINK/rgw/RegWillsonusesadifferentnotationforthecameraparameters.Thefollowingtablegivesthecorrespondencebetweenthetwonotationschemes:OurnotationWillsonsnotationfc(1)f.sx/dpxfc(2)f/dpycc(1)Cxcc(2)Cyalpha_c0Willsonusesafirstorderradialdistortionmodel(withanadditionalconstantk

29、appa1)thatdoesnothaveaneasyclosed-formcorespondencewithourdistortionmodel(encodedwiththecoefficientskc(1),.,kc(5).However,weincludedinthetoolboxafunctioncalledwillson_convertthatconvertstheentiresetofWillsonsparametersintoourparameters(includingdistortion).Thisfunctioniscalledinanotherfunctionwillso

30、n_readthatdirectlyloadsinacalibrationresultfilegeneratedbyWillsonscodeandcomputesthesetparameters(intrinsicandextrinsic)followingournotation(tousethatfunction,firstsetthematlabvariablecalib_filetothenameoftheoriginalwillsoncalibrationfile).AfewextracommentsonWillsonsmodel:SimilarlytoHeikkilmodel,the

31、skewisnotincludedinthemodel(alpha_c=0).SimilarlytoHeikkilmodel,thefourvariables(f,sx,dpx,dpy)replacingthe2x1focalvectorfcareingeneralimpossibletoestimateseparately.Itisonlypossibleiftwoofthosevariablesareknown(forexamplethemetricfocalvaluefandthescalefactorsx).Extrinsicparameters:Rotations:Asetofn_i

32、ma3x3rotationmatricesRc_1,Rc_2,.,Rc_20(assumingn_ima=20).Translations:A外部参数Rc和Tc同时注意n_ima好像是图片的数量(对一个镜头进行参数估计的图片数量)setofn_ima3x1vectorsTc_1,Tc_2,.,Tc_20(assumingn_ima=20).Definitionoftheextrinsicparameters:Considerthecalibrationgrid#i(attachedtotheithcalibrationimage),andconcentrateonthecamerarefere

33、nceframeattahedtothatgrid.Withoutlossofgenerality,takei=1.Thefollowingfigureshowsthereferenceframe(O,X,Y,Z)attachedtothatcalibrationgid.LetPbeapointspaceofcoordinatevectorXX=X;Y;Zinthegridreferenceframe(referenceframeshownonthepreviousfigure).LetXXc=Xc;Yc;ZcbethecoordinatevectorofPinthecamerareferenceframe.ThenXXandXXcarerelatedtoeachotherthroughthefollowingrigidmotionequation:XXc=Rc_1*XX+Tc_1XXc=Rc_1*XX+Tc_1世界坐标系到相机坐标系的投影,用两个外部参数矩阵Inparticular,thetransla

温馨提示

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

评论

0/150

提交评论