本文解决项目中“Basics of Image Formation”部分的问题,也就是实现从世界坐标向像素坐标的转换。
文件位置:Algorithms-for-Automated-Driving-master \code\exercises\lane_detection\camera_geometry.py
代码中写了详细注释。
import numpy as np
def get_intrinsic_matrix(field_of_view_deg, image_width, image_height):
"""
Returns intrinsic matrix K.
"""
# For our Carla camera alpha_u = alpha_v = alpha
# alpha 可以由所给相机的视场计算
field_of_view_rad = field_of_view_deg * np.pi/180
alpha = (image_width / 2.0) / np.tan(field_of_view_rad / 2.)
alpha_u = alpha_v = alpha
# 主点通常位于图像中央
u_0 = image_width / 2
v_0 = image_height / 2
# TODO step 1: Complete this