Skip to content

Commit

Permalink
feat: add JSONStreamCamera
Browse files Browse the repository at this point in the history
  • Loading branch information
tklockau committed Nov 4, 2024
1 parent 6b1161e commit 4f6e0e3
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions raillabel/json_format/stream_camera.py
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit 4f6e0e3

Please sign in to comment.