You are on page 1of 5

8/11/2016

WhatIsCameraCalibration?MATLAB&Simulink

WhatIsCameraCalibration?
Geometriccameracalibration,alsoreferredtoascameraresectioning,estimatestheparametersofalensandimage
sensorofanimageorvideocamera.Youcanusetheseparameterstocorrectforlensdistortion,measurethesizeof
anobjectinworldunits,ordeterminethelocationofthecamerainthescene.Thesetasksareusedinapplications
suchasmachinevisiontodetectandmeasureobjects.Theyarealsousedinrobotics,fornavigationsystems,and3
Dscenereconstruction.
Examplesofwhatyoucandoaftercalibratingyourcamera:

Cameraparametersincludeintrinsics,extrinsics,anddistortioncoefficients.Toestimatethecameraparameters,you
needtohave3Dworldpointsandtheircorresponding2Dimagepoints.Youcangetthesecorrespondencesusing
multipleimagesofacalibrationpattern,suchasacheckerboard.Usingthecorrespondences,youcansolveforthe
cameraparameters.Afteryoucalibrateacamera,toevaluatetheaccuracyoftheestimatedparameters,youcan:

Plottherelativelocationsofthecameraandthecalibrationpattern

Calculatethereprojectionerrors.

Calculatetheparameterestimationerrors.

UsetheCameraCalibratortoperformcameracalibrationandevaluatetheaccuracyoftheestimatedparameters.

CameraModel
TheComputerVisionSystemToolboxcalibrationalgorithmusesthecameramodelproposedbyJeanYvesBouguet
[3].Themodelincludes:

Thepinholecameramodel[1].

Lensdistortion[2].

Thepinholecameramodeldoesnotaccountforlensdistortionbecauseanidealpinholecameradoesnothavealens.
Toaccuratelyrepresentarealcamera,thefullcameramodelusedbythealgorithmincludestheradialandtangential
lensdistortion.

PinholeCameraModel
Apinholecameraisasimplecamerawithoutalensandwithasinglesmallaperture.Lightrayspassthroughthe
apertureandprojectaninvertedimageontheoppositesideofthecamera.Thinkofthevirtualimageplaneasbeingin
frontofthecameraandcontainingtheuprightimageofthescene.

http://www.mathworks.com/help/vision/ug/cameracalibration.html?requestedDomain=www.mathworks.com

1/5

8/11/2016

WhatIsCameraCalibration?MATLAB&Simulink

Thepinholecameraparametersarerepresentedina4by3matrixcalledthecameramatrix.Thismatrixmapsthe3D
worldsceneintotheimageplane.Thecalibrationalgorithmcalculatesthecameramatrixusingtheextrinsicand
intrinsicparameters.Theextrinsicparametersrepresentthelocationofthecamerainthe3Dscene.Theintrinsic
parametersrepresenttheopticalcenterandfocallengthofthecamera.

Theworldpointsaretransformedtocameracoordinatesusingtheextrinsicsparameters.Thecameracoordinatesare
mappedintotheimageplaneusingtheintrinsicsparameters.

CameraCalibrationParameters
Thecalibrationalgorithmcalculatesthecameramatrixusingtheextrinsicandintrinsicparameters.Theextrinsic
parametersrepresentarigidtransformationfrom3Dworldcoordinatesystemtothe3Dcamera'scoordinatesystem.
Theintrinsicparametersrepresentaprojectivetransformationfromthe3Dcamera'scoordinatesintothe2Dimage
coordinates.

ExtrinsicParameters
Theextrinsicparametersconsistofarotation,R,andatranslation,t.Theoriginofthecamera'scoordinatesystemis
atitsopticalcenteranditsxandyaxisdefinetheimageplane.
http://www.mathworks.com/help/vision/ug/cameracalibration.html?requestedDomain=www.mathworks.com

2/5

8/11/2016

WhatIsCameraCalibration?MATLAB&Simulink

IntrinsicParameters
Theintrinsicparametersincludethefocallength,theopticalcenter,alsoknownastheprincipalpoint,andtheskew
coefficient.Thecameraintrinsicmatrix,K,isdefinedas:

fx 0 0

s fy 0

cx cy 1
Thepixelskewisdefinedas:

[cx cy] Opticalcenter(theprincipalpoint),inpixels.


(fx, fy) Focallengthinpixels.
fx = F /px
fy = F /py
F Focallengthinworldunits,typicallyexpressedinmillimeters.
(px, py) Sizeofthepixelinworldunits.
s Skewcoefficient,whichisnonzeroiftheimageaxesarenotperpendicular.
s = fy tan
DistortioninCameraCalibration
Thecameramatrixdoesnotaccountforlensdistortionbecauseanidealpinholecameradoesnothavealens.To
accuratelyrepresentarealcamera,thecameramodelincludestheradialandtangentiallensdistortion.
RadialDistortion
Radialdistortionoccurswhenlightraysbendmoreneartheedgesofalensthantheydoatitsopticalcenter.The
smallerthelens,thegreaterthedistortion.

Theradialdistortioncoefficientsmodelthistypeofdistortion.Thedistortedpointsaredenotedas(x distorted,y distorted):


xdistorted=x(1+k1*r2+k2*r4+k3*r6)
2

http://www.mathworks.com/help/vision/ug/cameracalibration.html?requestedDomain=www.mathworks.com

3/5

8/11/2016

WhatIsCameraCalibration?MATLAB&Simulink
2

ydistorted=y(1+k1*r +k2*r +k3*r )

x,yUndistortedpixellocations.xandyareinnormalizedimagecoordinates.Normalizedimagecoordinatesare
calculatedfrompixelcoordinatesbytranslatingtotheopticalcenteranddividingbythefocallengthinpixels.
Thus,xandyaredimensionless.

k 1,k 2,andk 3Radialdistortioncoefficientsofthelens.

r2:x 2+y 2

Typically,twocoefficientsaresufficientforcalibration.Forseveredistortion,suchasinwideanglelenses,youcan
select3coefficientstoincludek 3.
TangentialDistortion
Tangentialdistortionoccurswhenthelensandtheimageplanearenotparallel.Thetangentialdistortioncoefficients
modelthistypeofdistortion.

Thedistortedpointsaredenotedas(x distorted,y distorted):


xdistorted=x+[2*p1*x*y+p2*(r2+2*x2)]
ydistorted=y+[p1*(r2+2*y2)+2*p2*x*y]

x,yUndistortedpixellocations.xandyareinnormalizedimagecoordinates.Normalizedimagecoordinatesare
calculatedfrompixelcoordinatesbytranslatingtotheopticalcenteranddividingbythefocallengthinpixels.
Thus,xandyaredimensionless.

p1andp2Tangentialdistortioncoefficientsofthelens.

r2=x 2+y 2

References
[1]Zhang,Z."AFlexibleNewTechniqueforCameraCalibration."IEEETransactionsonPatternAnalysisandMachine
Intelligence.Vol.22,No.11,2000,pp.13301334.
[2]Heikkila,J.,andO.Silven."AFourstepCameraCalibrationProcedurewithImplicitImageCorrection."IEEE
InternationalConferenceonComputerVisionandPatternRecognition.1997.
[3]Bouguet,J.Y."CameraCalibrationToolboxforMatlab."ComputationalVisionattheCaliforniaInstituteof
Technology.CameraCalibrationToolboxforMATLAB.
[4]Bradski,G.,andA.Kaehler.LearningOpenCV:ComputerVisionwiththeOpenCVLibrary.Sebastopol,CA:
O'Reilly,2008.

SeeAlso
CameraCalibrator|SingleCameraCalibrationApp

RelatedExamples

EvaluatingtheAccuracyofSingleCameraCalibration

http://www.mathworks.com/help/vision/ug/cameracalibration.html?requestedDomain=www.mathworks.com

4/5

8/11/2016

WhatIsCameraCalibration?MATLAB&Simulink

MeasuringPlanarObjectswithaCalibratedCamera

StructureFromMotionFromTwoViews

http://www.mathworks.com/help/vision/ug/cameracalibration.html?requestedDomain=www.mathworks.com

5/5

You might also like