(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是攝像機焦距。針孔中的點被理解成投影中心。光軸與圖像平面的交點被稱為主點。
你也許認為主點即成像儀的中心,但這意味着需要極其精度的安裝,實際上,通常中心不在光軸上。因此引入了兩個新的參數Cx和Cy,對偏移進行建模;由於單個像素點在低價成像儀上是矩形而不是正方形,引入兩個不同的焦距fx和fy(單位為像素),焦距fx實際上是透鏡的物理焦距長度與成像儀每個單元尺寸Sx的乘積,fy同理。
1.x=fx(X/Z)+Cx ; y=fy(Y/Z)+Cy 【圖像點(x,y);物理點(X,Y,Z)】
2.q=QM ; ;
二、內參數標定給出初始化后的標定結果和優化后的標定結果。其中,對內參數的優化采用L-M梯度下降法。優化后的結果中給出的參數不確定性,是3倍的標准方差。
fc中的兩個數據分別是kx和ky,即焦距歸一化成像平面上的成像點坐標到圖像坐標的放大系數。
cc為光軸中心點的圖像坐標(u0, v0),又稱為主點坐標(光軸和像平面的交點),單位:像素。
alpha_c是對應於圖像坐標v的攝像機的實際y軸與理想y軸之間的夾角ac,單位為弧度,默認值為0弧度。后續給出的圖像軸之間的夾角為對應於圖像坐標u、v的攝像機的x、y軸之間的夾角,默認值為90°。
est_alpha是alpha_c是否標定的標志位,只有est_alpha=1時對alpha_c進行標定。
kc為畸變系數kc1~kc5,kc(1)為二階徑向畸變系數kc1,kc(2)為4階徑向畸變系數kc2,kc(5)為6階徑向畸變系數kc5,kc(3)為圖像坐標u對應於xy項的切向畸變系數kc3,kc(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)//圖形坐標(單位(dx,dy))
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為靶標坐標系原點在攝像機坐標系中的位移向量,單位為mm;omc_ext為對應於姿態矩陣的rodrigues旋轉向量;Rc_ext為旋轉矩陣;err為將網格角點反投影到圖像空間的誤差的標准方差,單位為像素。