環境:
Matlab R2016a ,只有2014a以后的版本才有stereoCalibrator這個工具箱
參數解釋:
輸入參數:
size of checkboard suqare =83mm:
標定板一個小格的邊長。這是所有輸入量中唯一一個有世界尺度信息的量,用於把以像素為單位的值轉化成以mm或者m為單位的值;
左右相機圖片:
盡量使標定板占滿圖片;
estimate skew = ture:
Camera axes skew, specified as a scalar. If the x and the y axes are exactly perpendicular, then set the skew to 0
.
相機x,y軸的傾斜,是個標量。如果x,y完全垂直,則skew=0;
我標定后得到的結果skew值不為0~說明xy軸不完全垂直,可能也是后面求disparity不准的原因之一吧。
camera distortion 畸變參數
徑向畸變系數的個數,2 coefficient或者3 ~; 切向畸變 estimateTangentialDistortion = true
解釋:
徑向畸變是,坐標點距離原點的長度不正常;切向畸變是,坐標點沿着切線方向發生變化,水平夾角異常 -- 高博SLAM十四講
1 radial distortion 徑向畸變
Radial distortion coefficients, specified as either a 2- or 3-element vector. When you specify a 2-element vector, the object sets the third element to 0
. Radial distortion occurs when light rays bend more near the edges of a lens than they do at its optical center. The smaller the lens, the greater the distortion. The camera parameters object calculates the radial distorted location of a point. You can denote the distorted points as (xdistorted, ydistorted), as follows:
徑向畸變系數,2元或者3元向量。用來矯正由透鏡形狀引起的徑向畸變(光線穿過透鏡時,在透鏡邊緣彎曲程度大於靠近中心處的彎曲程度,造成桶形失真或者枕形失真)。
枕形失真
桶形失真
所以用k1,k2,k3三個參數矯正徑向畸變。
xdistorted = x(1 + k1*r2 + k2*r4 + k3*r6)
ydistorted= y(1 + k1*r2 + k2*r4 + k3*r6)
x, y = undistorted pixel locations |
k1, k2, and k3 = radial distortion coefficients of the lens |
r2 = x2 + y2 |
高翔《視覺SLAM十四講》中寫到:對於畸變較小的圖像中心區域,主要是k1起作用;對於畸變較大的邊緣區域主要是k2起作用。普通相機這兩個系數就夠用了,
對於魚眼相機這種畸變特別大的才用的上第三個參數k3
Typically, two coefficients are sufficient. For severe distortion, you can include k3. The undistorted pixel locations appear in normalized image coordinates, with the origin at the optical center. The coordinates are expressed in world units.
去畸變后的點位於歸一化平面上(不是像素平面),原點在光心。坐標以世界單位(默認毫米)表示。
2 tangential distortion 切向畸變
Tangential distortion coefficients, specified as a 2-element vector. Tangential distortion occurs when the lens and the image plane are not parallel. The camera parameters object calculates the tangential distorted location of a point. You can denote the distorted points as (xdistorted, ydistorted), as follows:
切向畸變是由鏡頭和成像平面不完全平行引起的。由兩個元素p1,p2矯正:
xdistorted = x + [2 * p1 * y + p2 * (r2 + 2 * x2)]
ydistorted = y + [p1 * (r2 + 2*y2) + 2 * p2 * x]
x, y = undistorted pixel locations |
p1 and p2 = tangential distortion coefficients of the lens |
r2 = x2 + y2 |
The undistorted pixel locations appear in normalized image coordinates, with the origin at the optical center. The coordinates are expressed in world units.
同上。
worldunit 現實世界中的單位,默認毫米
輸出的translationVector是以世界坐標系為單位,而兩個相機的內參則是以像素為單位
輸出參數
雙目參數:
RotationOfCamera2: 相機2相對於相機1的旋轉矩陣
TranslationOfCamera2:相機2相對於相機1的平移矩陣 ,此處注意,以世界單位mm為單位
FundamentalMatrix: 基礎矩陣 F
CameraParameters1:
徑向畸變切向畸變相關參數上面已經解釋過
InstrinsicMatrix:相機內參矩陣 的轉置
Projection matrix, specified as a 3-by-3 identity matrix. The object uses the following format for the matrix format:
3乘3的投影矩陣
fx,fy是焦距F分別乘上x,y方向上的縮放系數sx,sy得到的。以像素為單位 。sx表示x方向上每個world unit內像素的數量
cx,cy表示光心在圖像坐標系上的投影的坐標(也就是圖像坐標系與相機坐標系之間的偏移)
The coordinates [cx cy] represent the optical center (the principal point), in pixels. When the x and y axis are exactly perpendicular, the skew parameter, s, equals 0
.
fx = F*sx |
fy = F*sy |
F, is the focal length in world units, typically expressed in millimeters. |
[sx, sy] are the number of pixels per world unit in the x and y direction respectively. |
fx and fy are expressed in pixels. |
FocalLength和PrincipalPoint,也就是內參矩陣里的fx,fy,cx,cy