Skip to content

Update sensor size #1163

@TheMr33

Description

@TheMr33

Describe your feature request

I have the specifications of a camera (sensor size in mm, focal distance, field of view etc…) and I would like to create a virtual camera that would mirror those parameters. However it does not seem possible to update the sensor size using the camera api. As a result, even if the field of view is correct, the parameters of the focal length no longer match the one of the original camera.

Describe a possible solution

A simple solution would be to add a function like:

def set_sensor_size(cam: bpy.types.Camera, sensor_width_in_mm: float = None, sensor_height_in_mm: float = None):
    """ Update the sensor size of the camera.

    :param cam: The camera object.
    :param sensor_width_in_mm: width of the sensor in mm.
    :param sensor_height_in_mm: height of the sensor in mm.
    """
    if sensor_width_in_mm is not None:
        cam.sensor_width = sensor_width_in_mm
    if sensor_height_in_mm is not None:
        cam.sensor_height = sensor_height_in_mm

and call this function at the beginning of set_intrinsics_from_K_matrix and set_intrinsics_from_blender_params (and maybe set_resolution?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions