Fisheye distortion

カメラ座標

Pc=(XcYcZc)P_c = \left( \begin{array}{c} X_c \\ Y_c \\ Z_c \end{array} \right)
x=Xc/Zcy=Yc/Zcr2=x2+y2θ=atan(r)x' = X_c / Z_c \\ y' = Y_c / Z_c \\ r^2 = x'^2 + y'^2 \\ \theta = {\rm atan}(r)

歪み補正 / Distortion correction

θd=θ(1+k1θ2+k2θ4+k3θ6+k4θ8)x=θdrxy=θdry\theta_d = \theta ( 1 + k_1 \theta^2 + k_2 \theta^4 + k_3 \theta^6 + k_4 \theta^8 )\\ x'' = \frac{ \theta_d }{r} x' \\ y'' = \frac{ \theta_d }{r} y'

カメラ座標変換

(uv)=(fx0cx0fycy)(xy1)\left( \begin{array}{c} u \\ v \end{array} \right) = \left( \begin{array}{ccc} f_x & 0 & c_x \\ 0 & f_y & c_y \\ \end{array} \right) \left( \begin{array}{c} x'' \\ y'' \\ 1 \end{array} \right)

OpenCV

K = np.array([
[ 1, 0, 320 ],
[ 0, 1, 240 ],
[ 0, 0, 1 ],
], dtype=np.float32)
D = np.array([ 1, 0, 0, 0 ], dtype=np.float32)
undistorted_points = np.array([[
[ 0, 0 ],
[ 0, 10 ],
[ 10, 0 ],
[ 10, 10 ],
]], dtype=np.float32)
distorted_points = cv2.fisheye.distortPoints(undistorted_points, K, D)
distorted_points
array([[[320. , 240. ],
[320. , 244.65497],
[324.65497, 240. ],
[323.44827, 243.44826]]], dtype=float32)