def get_computer_vision_camera(
    blender_camera,
    camera_name,
    image_dp=None,
    camera_index=None,
    check_scale=True,
    op=None,
):
    """Derive a camera object from a Blender camera object."""

    calibration_mat = get_calibration_mat(blender_camera)
    camera_matrix_computer_vision = (
        get_computer_vision_camera_transformation_matrix(
            blender_camera, check_scale, op
        )
    )

    camera = Camera()
    camera.id = camera_index
    camera.set_relative_fp(camera_name, Camera.IMAGE_FP_TYPE_NAME)
    camera.image_dp = image_dp
    camera.width = bpy.context.scene.render.resolution_x
    camera.height = bpy.context.scene.render.resolution_y
    camera.set_calibration(calibration_mat, radial_distortion=0)
    camera.set_4x4_cam_to_world_mat(
        camera_matrix_computer_vision, check_rotation=check_scale
    )
    return camera
Derive a camera object from a Blender camera object.
photogrammetry_importer/importers/camera_utility.py