def cameras_to_intrinsics()

in utils/load_colmap.py [0:0]


def cameras_to_intrinsics(cameras, camera_ids, size_new):
    """
    Args:
        size_new: image size after resizing and produce equivalent intrinsics
        for this size
    """
    # params = f, cx, cy
    assert all(
        (c.model == "SIMPLE_PINHOLE" or c.model == "PINHOLE"
            or c.model == "SIMPLE_RADIAL"
         for c in cameras.values()))

    intrinsics = []
    for id in camera_ids:
        c = cameras[id]
        if c.model == "SIMPLE_PINHOLE":
            f, cx, cy = c.params
            fxy = np.array([f, f])
        elif c.model == "PINHOLE":
            fx, fy, cx, cy = c.params
            fxy = np.array([fx, fy])
        elif c.model == "SIMPLE_RADIAL":
            f, cx, cy, r = c.params
            fxy = np.array([f, f])
        else:
            raise AssertionError()
        ratio = np.array(size_new) / np.array((c.width, c.height))
        fxy = fxy * ratio
        cxy = np.array((cx, cy)) * ratio
        intrinsics.append(np.concatenate((fxy, cxy)))
    return np.stack(intrinsics, axis=0)