dstImg np.zeros(img.shape, np.uint8)
ux, uy w/2, h/2 # 传统图像的主点 principle point 也是鱼眼的主点 因为同分辨率的
for i in range(h):
for j in range(w):
dx, dy j-ux, i-uy # 传统图像的图像坐标
rc np.sqrt(dx**2 dy**2) # distance between the image point and the principal point
theta np.arctan2(rc, self.focal_length) # θ is the angle between the principal axis and the incoming ray
gama np.arctan2(dy, dx) # 图像点到图像主点的连线的角度 鱼眼和传统都一样
rf self.focal_length*theta
xf rf*np.cos(gama)
yf rf*np.sin(gama)
x int(xf ux) # 原图j对应鱼眼的x
y int(yf uy) # 原图i对应鱼眼的y
dstImg[y][x] img[i][j]
# cv2.imshow( a , dstImg)
# cv2.waitKey()
return(dstImg)