camera_utils.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:vsi_common 作者: VisionSystemsInc 项目源码 文件源码
def construct_K(image_size, focal_len=None, fov_degrees=None, fov_radians=None):
  """ create calibration matrix K using the image size and focal length or field of view angle
  Assumes 0 skew and principal point at center of image
  Note that image_size = (width, height)
  Note that fov is assumed to be measured horizontally
  """
  if not np.sum([focal_len is not None, fov_degrees is not None, fov_radians is not None]) == 1:
    raise Exception('Specify exactly one of [focal_len, fov_degrees, fov_radians]')

  if fov_degrees is not None:
    fov_radians = np.deg2rad(fov_degrees)
  if fov_radians is not None:
    focal_len = image_size[0] / (2.0 * np.tan(fov_radians/2.0))

  K = np.array([[focal_len, 0, image_size[0]/2.0], [0, focal_len, image_size[1]/2.0], [0, 0, 1]])
  return K
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号