def read_calibration(cam, extrinsics=False):
    K = np.array([[cam['focal_length_px'][0], 0, cam['center_px'][0]], [0, cam['focal_length_px'][1], cam['center_px'][1]], [0, 0, 1]])
    D = np.array(cam['distortion']['k'])
    if extrinsics:
        H = np.eye(4)
        H[:3, :3] = np.reshape(cam['extrinsics']['R'], (3, 3))
        H[:3, 3] = cam['extrinsics']['T']
        return (K, D, H)
    return (K, D)
def read_calibration(cam, extrinsics=False):
    K = np.array([[cam['focal_length_px'][0], 0, cam['center_px'][0]], [0, cam['focal_length_px'][1], cam['center_px'][1]], [0, 0, 1]])
    D = np.array(cam['distortion']['k'])
    if extrinsics:
        H = np.eye(4)
        H[:3, :3] = np.reshape(cam['extrinsics']['R'], (3, 3))
        H[:3, 3] = cam['extrinsics']['T']
        return (K, D, H)
    return (K, D)