from typing import Optional from pydantic import BaseModel class CameraParameters(BaseModel): focal_length: float sensor_width: float sensor_height: float resolution_width: int resolution_height: int principal_point: tuple[float, float] | None = None distortion_coefficients: list[float] | None = None def get_principal_point(self) -> tuple[float, float]: if self.principal_point: return self.principal_point return (self.resolution_width / 2.0, self.resolution_height / 2.0)