From 4f6e0e3ff08acecfcf22520852e7eee903dc8732 Mon Sep 17 00:00:00 2001 From: Tobias Klockau Date: Mon, 4 Nov 2024 08:46:17 +0100 Subject: [PATCH] feat: add JSONStreamCamera --- raillabel/json_format/stream_camera.py | 55 ++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 raillabel/json_format/stream_camera.py diff --git a/raillabel/json_format/stream_camera.py b/raillabel/json_format/stream_camera.py new file mode 100644 index 0000000..c268acf --- /dev/null +++ b/raillabel/json_format/stream_camera.py @@ -0,0 +1,55 @@ +# Copyright DB InfraGO AG and contributors +# SPDX-License-Identifier: Apache-2.0 + +from __future__ import annotations + +from typing import Literal + +from pydantic import BaseModel + + +class JSONStreamCamera(BaseModel): + """A stream describes the source of a data sequence, usually a sensor. + + This specific object contains the intrinsics of a camera sensor. + """ + + type: Literal["camera"] + "A string encoding the type of the stream." + + stream_properties: JSONStreamCameraProperties + "Intrinsic calibration of the stream." + + uri: str + "A string encoding the subdirectory containing the sensor files." + + description: str | None + "Description of the stream." + + +class JSONStreamCameraProperties(BaseModel): + """Intrinsic calibration of the stream.""" + + intrinsics_pinhole: JSONIntrinsicsPinhole + + +class JSONIntrinsicsPinhole(BaseModel): + """JSON object defining an instance of the intrinsic parameters of a pinhole camera.""" + + camera_matrix: tuple[ + float, float, float, float, float, float, float, float, float, float, float, float + ] + """This is a 3x4 camera matrix which projects 3D homogeneous points (4x1) from a camera + coordinate system into the image plane (3x1). This is the usual K matrix for camera projection as + in OpenCV. It is extended from 3x3 to 3x4 to enable its direct utilisation to project 4x1 + homogeneous 3D points. The matrix is defined to follow the camera model: x-to-right, y-down, + z-forward. The following equation applies: x_img = camera_matrix * X_ccs.""" + + distortion_coeffs: tuple[float, float, float, float, float] + "This is the array 1x5 radial and tangential distortion coefficients." + + height_px: int + "Height of the camera output in pixel." + + width_px: int + "Width of the camera output in pixel."