码迷,mamicode.com
首页 > 其他好文 > 详细

利用matlab摄像机标定

时间:2016-11-19 21:03:21      阅读:419      评论:0      收藏:0      [点我收藏+]

标签:atl   pat   actual   variable   image   模型   引号   let   put   

(1)输入图像

“Image names”键

Matlab的图形窗口显示出20幅靶标图像

 技术分享

(2) 提取角点

“Extract grid corners”键。

输入要进行角点提取的靶标图像的编号并回车

分别在“wintx ([] = 5) =”和“winty ([] = 5) =”输入行中输入角点提取区域的窗口半宽m和半高n。显示角点提取区域的窗口尺寸(2n+1)x(2m+1),例如,选择缺省时角点提取区域的窗口尺寸为11x11像素。

Extraction of the grid corners on the images

Number(s) of image(s) to process ([] = all images) = 17

Window size for corner finder (wintx and winty):

wintx ([] = 5) = 5

winty ([] = 5) = 5

Window size = 11x11

 

Do you want to use the automatic square counting mechanism (0=[]=default)

  or do you always want to enter the number of squares manually (1,other)? 0

//0表示自动计算棋盘格靶标选定区域内的方格行数和列数,选择值1表示人工计算并输入棋盘格靶标选定区域内的方格行数和列数。

 

Processing image 17...

Using (wintx,winty)=(5,5) - Window size = 11x11      (Note: To reset the window size, run script clearwin)

Click on the four extreme corners of the rectangular complete pattern (the first clicked corner is the origin)...//点击四个极端的角落的矩形完整的模式(第一个点击的角落是原点)

Size of each square along the X direction: dX=100mm//沿X方向每平方大小:DX = 100mm

Size of each square along the Y direction: dY=100mm   (Note: To reset the size of the squares, clear the variables dX and dY)

If the guessed grid corners (red crosses on the image) are not close to the actual corners,

it is necessary to enter an initial guess for the radial distortion factor kc (useful for subpixel detection)//如果猜到的网格角(图像上的红色的十字架)不接近实际的角落,需要输入径向畸变系数Kc的初始猜测(用于亚像素检测)

Need of an initial guess for distortion? ([]=no, other=yes) []

需要一个初始猜测的失真?(=不,其他=是)

Corner extraction...角点提取…

done完成

 技术分享

技术分享

(3) 内参数标定

“Calibration”键

一、摄像机模型:

f是摄像机焦距。针孔中的点被理解成投影中心。光轴与图像平面的交点被称为主点。

你也许认为主点即成像仪的中心,但这意味着需要极其精度的安装,实际上,通常中心不在光轴上。因此引入了两个新的参数CxCy,对偏移进行建模;由于单个像素点在低价成像仪上是矩形而不是正方形,引入两个不同的焦距fxfy(单位为像素),焦距fx实际上是透镜的物理焦距长度与成像仪每个单元尺寸Sx的乘积,fy同理。

1.x=fxX/Z+Cx  y=fyY/Z+Cy 【图像点(x,y);物理点(X,Y,Z)】

2.q=QM     ;    ;     

 

二、内参数标定给出初始化后的标定结果和优化后的标定结果。其中,对内参数的优化采用L-M梯度下降法。优化后的结果中给出的参数不确定性,是3倍的标准方差。

fc中的两个数据分别是kxky,即焦距归一化成像平面上的成像点坐标到图像坐标的放大系数。

cc为光轴中心点的图像坐标(u0, v0),又称为主点坐标(光轴和像平面的交点),单位:像素。

alpha_c是对应于图像坐标v摄像机的实际y轴与理想y轴之间的夹角ac,单位为弧度,默认值为0弧度。后续给出的图像轴之间的夹角为对应于图像坐标uv摄像机的xy轴之间的夹角,默认值为90°

est_alphaalpha_c是否标定的标志位,只有est_alpha=1时对alpha_c进行标定。

kc为畸变系数kc1~kc5kc(1)为二阶径向畸变系数kc1kc(2)4阶径向畸变系数kc2kc(5)6阶径向畸变系数kc5kc(3)图像坐标u对应于xy项的切向畸变系数kc3kc(4)图像坐标v对应于xy项的切向畸变系数kc4

err为将网格角点反投影到图像空间的误差的标准方差,单位为像素。

在优化后的结果中,不确定性的数值越小,说明标定的精度越高。如果不确定性项的数值与结果值相比所占比例较大,则需要重新标定。

初始化后的标定结果:

Calibration parameters after initialization:

Focal Length:          fc = [ 2261.90405   2109.71287 ]

Principal point:       cc = [ 319.50000   239.50000 ]

Skew:             alpha_c = [ 0.00000 ]   => angle of pixel = 90.00000 degrees

Distortion:            kc = [ 0.00000   0.00000   0.00000   0.00000   0.00000 ]

 

优化后的标定结果:

17

Calibration results after optimization (with uncertainties):

Focal Length:          fc = [ 1449.63020   1465.98311 ] +/- [ 400.52656   411.89609 ]

Principal point:       cc = [ 319.50000   239.50000 ] +/- [ 0.00000   0.00000 ]

Skew:   alpha_c = [ 0.00000 ] +/- [ 0.00000  ]  => angle of pixel axes = 90.00000 +/- 0.00000 degrees

Distortion:            kc = [ -0.73547   8.76011   -0.03983   -0.03329  0.00000 ] +/- [ 0.64286   18.37382   0.02206   0.00821  0.00000 ]

Pixel error:          err = [ 0.39436   0.41117 ]

16

Calibration results after optimization (with uncertainties):

Focal Length:          fc = [ 1057.47799   1065.08661 ] +/- [ 179.00243   182.45017 ]

Principal point:       cc = [ 319.50000   239.50000 ] +/- [ 0.00000   0.00000 ]

Skew:             alpha_c = [ 0.00000 ] +/- [ 0.00000  ]   => angle of pixel axes = 90.00000 +/- 0.00000 degrees

Distortion:            kc = [ -0.42145   2.71172   -0.02680   -0.02733  0.00000 ] +/- [ 0.27931   4.47689   0.01235   0.00609  0.00000 ]

Pixel error:          err = [ 0.39060   0.46655 ]

4

Calibration results after optimization (with uncertainties):

Focal Length:          fc = [ 981.15486   990.80729 ] +/- [ 83.68588   85.72653 ]

Principal point:       cc = [ 319.50000   239.50000 ] +/- [ 0.00000   0.00000 ]

Skew:             alpha_c = [ 0.00000 ] +/- [ 0.00000  ]   => angle of pixel axes = 90.00000 +/- 0.00000 degrees

Distortion:            kc = [ -0.31958   1.45735   -0.01584   -0.02388  0.00000 ] +/- [ 0.23908   3.49317   0.00665   0.00536  0.00000 ]

Pixel error:          err = [ 0.52427   0.49251 ]

   (4) 显示摄像机与标定靶标之间的关系

“Show Extrinsic”键

 技术分享

假设摄像机固定时摄像机与靶标之间的关系.

 

 技术分享

假设靶标固定时摄像机与靶标之间的关系

(5) 误差分析

“Analyse error”键

利用鼠标移动十字标尺可以选择角点,即可在命令窗口显示出该角点的信息,包括该角点所属图像、索引号、以方格为单位的坐标、图像坐标、反投影后的图像坐标误差、角点提取区域的窗口半宽m和半高n

 技术分享

Selected image: 17

Selected point index: 22 //选择点指数:22

Pattern coordinates (in units of (dX,dY)): (X,Y)=(0,3)//图形坐标(单位(dxdy))

Image coordinates (in pixel): (326.27,97.25)//图像坐标(像素)

Pixel error = (0.39891,0.38640)//像素误差

Window size: (wintx,winty) = (5,5)

(6) 反投影到图像空间

“Project on image”键

出现“Number(s) of image(s) to process ([] = all images) =”时,输入要进行反投影的靶标图像的编号并回车:

Number(s) of image(s) to show ([] = all images) = 17

Pixel error:      err = [0.52427   0.49251] (all active images)

 技术分享

(7) 图像畸变校正

“Undistort image”键

Program that undistorts images

The intrinsic camera parameters are assumed to be known (previously computed)

Do you want to undistort all the calibration images ([],0) or a new image (1)? 1

内在的相机参数被假定为已知(先前计算)

你想所有的校正图像失真([ ]0)或一个新的图像(1)?

 技术分享

技术分享

(8) 外参数标定

Comp. Extrinsic”键

 

外参数包括:旋转矩阵;平移向量,来描述物体的相对位置

 

外参数标定是在内参数已知的前提下进行的。在完成摄像机的内参数标定后,或者在命令窗口输入摄像机的内参数后,可以对棋盘格靶标相对于摄像机的外参数进行标定。

Computation of the extrinsic parameters from an image of a pattern

The intrinsic camera parameters are assumed to be known (previously computed)

 

Image name (full name without extension): image17

Image format: ([]=‘r‘=‘ras‘, ‘b‘=‘bmp‘, ‘t‘=‘tif‘, ‘p‘=‘pgm‘, ‘j‘=‘jpg‘, ‘m‘=‘ppm‘) j

 

Extraction of the grid corners on the image

Window size for corner finder (wintx and winty):

wintx ([] = 5) =

winty ([] = 5) =

Window size = 11x11

Click on the four extreme corners of the rectangular complete pattern (the first clicked corner is the origin)...

Size dX of each square along the X direction ([]=30mm) = 100

Size dY of each square along the Y direction ([]=30mm) = 100

Corner extraction...

 

 

Extrinsic parameters:

 

Translation vector: Tc_ext = [ -286.312743  -270.910076  2017.432436 ]

Rotation vector:   omc_ext = [ -2.148529  -2.100271  -0.134644 ]  旋转矢量

Rotation matrix:    Rc_ext = [ 0.025055  0.999247  -0.029640

旋转矩阵                       0.987282  -0.020077  0.157706

                               0.156992  -0.033214  -0.987041 ]

Pixel error:           err = [ 0.34478  0.42945 ]

外参数标定结果中,Tc_ext为靶标坐标系原点在摄像机坐标系中的位移向量,单位为mmomc_ext为对应于姿态矩阵的rodrigues旋转向量;Rc_ext为旋转矩阵;err将网格角点反投影到图像空间的误差的标准方差,单位为像素。

 

利用matlab摄像机标定

标签:atl   pat   actual   variable   image   模型   引号   let   put   

原文地址:http://www.cnblogs.com/Jessica-jie/p/6081308.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!