ncore.data Package#

Package exposing methods related to NCore’s basic data types and abstract APIs

class ncore.data.AsyncCameraLabelsProtocol(*args, **kwargs)#

Bases: CameraLabelsProtocol, Protocol

Camera labels with asynchronous reads of their data (see CameraLabelsProtocol for the synchronous API)

class CameraLabelHandleProtocol(*args, **kwargs)#

Bases: CameraLabelHandleProtocol, Protocol

A single camera label at a specific timestamp, loadable synchronously or asynchronously

async get_data_async() → npt.NDArray[Any]#

Loads and returns the label data as a numpy array, read asynchronously

async get_encoded_data_async() → bytes | None#

Returns raw encoded bytes for IMAGE_ENCODED labels (None for RAW labels), read asynchronously

get_label(
timestamp_us: int,
) → CameraLabelHandleProtocol#

Return a lazy handle to the label data at the given timestamp (loadable synchronously or asynchronously)

class ncore.data.AsyncCameraSensorProtocol(*args, **kwargs)#

Bases: AsyncSensorProtocol, CameraSensorProtocol, Protocol

A camera sensor with asynchronous reads of its data (see CameraSensorProtocol for the synchronous API)

class EncodedImageDataHandleProtocol(
*args,
**kwargs,
)#

Bases: EncodedImageDataHandleProtocol, Protocol

References encoded image data without loading it (synchronously or asynchronously)

async get_data_async() → EncodedImageData#

Loads the referenced encoded image data to memory asynchronously

async get_frame_data_async(
frame_index: int,
) → EncodedImageData#

Returns the frame’s encoded image data, read asynchronously (decode it via EncodedImageData.get_decoded_image(), e.g., in a worker pool)

get_frame_handle(
frame_index: int,
) → EncodedImageDataHandleProtocol#

Returns a handle of the frame’s encoded image data (loadable synchronously or asynchronously)

async get_mask_images_async() → Dict[str, Image]#

Returns all available named camera mask images, read asynchronously

class ncore.data.AsyncLidarSensorProtocol(*args, **kwargs)#

Bases: AsyncRayBundleSensorProtocol, LidarSensorProtocol, Protocol

A lidar sensor with asynchronous reads of its data (see LidarSensorProtocol for the synchronous API)

async get_frame_ray_bundle_model_element_async(
frame_index: int,
) → npt.NDArray[np.uint16] | None#

Returns the per-ray model elements for a ray bundle for a specific frame [N,] (None if not available), read asynchronously

async get_frame_ray_bundle_return_intensity_async(
frame_index: int,
return_index: int = 0,
) → npt.NDArray[np.float32]#

Returns the per-ray measured intensities for a ray bundle return for a specific frame [N,], read asynchronously

class ncore.data.AsyncPointCloudsSourceProtocol(*args, **kwargs)#

Bases: PointCloudsSourceProtocol, Protocol

A point-clouds source with asynchronous reads of its data (see PointCloudsSourceProtocol for the synchronous API)

async get_pc_async(
pc_index: int,
) → PointCloud#

Returns the point cloud at pc_index like PointCloudsSourceProtocol.get_pc(), with its points read asynchronously (attributes are loaded lazily, as for PointCloudsSourceProtocol.get_pc(): their loads on access are synchronous reads)

async get_pc_generic_data_async(
pc_index: int,
name: str,
) → npt.NDArray#

Returns a generic data array by name for the given point cloud, read asynchronously

class ncore.data.AsyncRadarSensorProtocol(*args, **kwargs)#

Bases: AsyncRayBundleSensorProtocol, RadarSensorProtocol, Protocol

A radar sensor with asynchronous reads of its data (see RadarSensorProtocol for the synchronous API)

class ncore.data.AsyncRayBundleSensorPointCloudsSourceAdapter(
sensor: AsyncRayBundleSensorProtocol,
*,
return_index: int = 0,
promote_generic_data: Dict[str,
~ncore.impl.data.compat.RayBundleSensorPointCloudsSourceAdapter.GenericDataPromotion]={'rgb': RayBundleSensorPointCloudsSourceAdapter.GenericDataPromotion(shape_suffix=(3,
),
transform_type=<AttributeTransformType.INVARIANT: 0>)},
)#

Bases: RayBundleSensorPointCloudsSourceAdapter

Adapts an AsyncRayBundleSensorProtocol (lidar or radar) into AsyncPointCloudsSourceProtocol (see RayBundleSensorPointCloudsSourceAdapter), reading point clouds asynchronously.

The protocol is declared after this class (the asynchronous protocols are defined at the end of the module), so conformance is structural.

async get_pc_async(
pc_index: int,
) → PointCloud#

Returns the point cloud of a sensor frame with its points (and model elements) read asynchronously (see RayBundleSensorPointCloudsSourceAdapter for its attributes: lazily loaded ones are read synchronously on access)

async get_pc_generic_data_async(
pc_index: int,
name: str,
) → npt.NDArray#
class ncore.data.AsyncRayBundleSensorProtocol(*args, **kwargs)#

Bases: AsyncSensorProtocol, RayBundleSensorProtocol, Protocol

A ray-bundle sensor with asynchronous reads of its data (see RayBundleSensorProtocol for the synchronous API)

async get_frame_point_cloud_async(
frame_index: int,
motion_compensation: bool,
with_start_points: bool,
return_index: int = 0,
) → FramePointCloud#

Returns a frame point cloud like RayBundleSensorProtocol.get_frame_point_cloud(), with its data read asynchronously (concurrently)

async get_frame_ray_bundle_direction_async(
frame_index: int,
) → npt.NDArray[np.float32]#

Returns the per-ray directions for the ray-bundle for a specific frame [N,3], read asynchronously

async get_frame_ray_bundle_return_distance_m_async(
frame_index: int,
return_index: int = 0,
) → npt.NDArray[np.float32]#

Returns the per-ray measured metric distances for the ray bundle returns of a specific frame [N,], read asynchronously

async get_frame_ray_bundle_return_valid_mask_async(
frame_index: int,
return_index: int = 0,
) → npt.NDArray[np.bool_]#

Returns the per-ray valid mask for the ray bundle returns of a specific frame [N], read asynchronously

async get_frame_ray_bundle_timestamp_us_async(
frame_index: int,
) → npt.NDArray[np.uint64]#

Returns the per-ray timestamps for the ray-bundle for a specific frame [N,], read asynchronously

class ncore.data.AsyncSensorProtocol(*args, **kwargs)#

Bases: SensorProtocol, Protocol

A sensor with asynchronous reads of its data (see SensorProtocol for the synchronous API)

async get_frame_generic_data_async(
frame_index: int,
name: str,
) → npt.NDArray[Any]#

Returns generic frame-data for a specific frame and name, read asynchronously

class ncore.data.AsyncSequenceLoaderProtocol(*args, **kwargs)#

Bases: SequenceLoaderProtocol, Protocol

A sequence loader whose sensors, point-clouds sources and camera labels support asynchronous reads of their data (see SequenceLoaderProtocol for the synchronous API).

Example:

async def load_frames(loader: AsyncSequenceLoaderProtocol, camera_id: str, frame_indices: List[int]):
    camera = loader.get_camera_sensor(camera_id)
    return await asyncio.gather(*(camera.get_frame_data_async(i) for i in frame_indices))
get_camera_labels(
camera_label_id: str,
) → AsyncCameraLabelsProtocol#

Get a camera label instance (with asynchronous reads) by instance ID.

get_camera_sensor(
sensor_id: str,
) → AsyncCameraSensorProtocol#

Returns a camera sensor instance (with asynchronous reads) for a given sensor id

get_lidar_sensor(
sensor_id: str,
) → AsyncLidarSensorProtocol#

Returns a lidar sensor instance (with asynchronous reads) for a given sensor id

get_point_clouds_source(
source_id: str,
*,
return_index: int = 0,
) → AsyncPointCloudsSourceProtocol#

Returns a point-clouds source (with asynchronous reads) for a given source id (see SequenceLoaderProtocol.get_point_clouds_source())

get_radar_sensor(
sensor_id: str,
) → AsyncRadarSensorProtocol#

Returns a radar sensor instance (with asynchronous reads) for a given sensor id

query_camera_labels(
camera_id: str,
label_type: LabelType | None = None,
label_category: LabelCategory | None = None,
) → Sequence[AsyncCameraLabelsProtocol]#

Query camera label instances (with asynchronous reads) matching filters (see SequenceLoaderProtocol.query_camera_labels())

class ncore.data.BBox3(
centroid: Tuple[float, float, float],
dim: Tuple[float, float, float],
rot: Tuple[float, float, float],
)#

Bases: DataClassJsonMixin

Parameters of a 3D bounding-box

centroid: Tuple[float, float, float]#

Coordinates [meters] of the bounding-box’s centroid in the frame of reference

dim: Tuple[float, float, float]#

Extents [meters] of the local bounding-box dimensions in its local frame

classmethod from_array(
array: ndarray,
) → BBox3#

Convert from convenience single-array representation

rot: Tuple[float, float, float]#

‘XYZ’ Euler rotation angles [radians] orienting the local bounding-box frame to the frame of reference

to_array() → ndarray#

Convert to convenience single-array representation

class ncore.data.BivariateWindshieldModelParameters(
reference_poly: ReferencePolynomial = None,
horizontal_poly: ndarray = None,
vertical_poly: ndarray = None,
horizontal_poly_inverse: ndarray = None,
vertical_poly_inverse: ndarray = None,
)#

Bases: ExternalDistortionParameters

Represents parameters required to create a windshield external distortion model

horizontal_poly: ndarray = None#

Polynomial coefficients used for forward projection on the horizontal component of a ray via its projected angle phi=asin(x/norm(x,y)). The polynomial is of order N in both phi and theta with the form P(phi,N)*P(theta,0) + P(phi, N-1)*P(theta,1) … + P(phi, N-N)*P(theta,N), where P(i, N) is a polynomial over “i” of degree N (float32, [(N + 1) * (N + 2) / 2,])

horizontal_poly_inverse: ndarray = None#

Polynomial coefficients used to evaluate the inverse distortion in backprojection of the horizontal component of a ray via its projected angle phi=asin(x/norm(x,y)). The polynomial is of order N in both phi and theta with the form P(phi,N)*P(theta,0) + P(phi, N-1)*P(theta,1) … + P(phi, N-N)*P(theta,N), where P(i, N) is a polynomial over “i” of degree N (float32, [(N + 1) * (N + 2) / 2,])

reference_poly: ReferencePolynomial = None#

Reference polynomial of the model

static type() → str#

Returns a string-identifier of the external distortion model

vertical_poly: ndarray = None#

Polynomial coefficients used for forward projection on the vertical component of a ray via its projected angle theta=asin(y/norm(x,y)). The polynomial is of order M in both phi and theta with the form P(phi,M)*P(theta,0) + P(phi, M-1)*P(theta,1) … + P(phi, M-M)*P(theta,M), where P(i, M) is a polynomial over “i” of degree M (float32, [(M + 1) * (M + 2) / 2,])

vertical_poly_inverse: ndarray = None#

Polynomial coefficients used to evaluate the inverse distortion in backprojection of the vertical component of a ray via its projected angle theta=asin(y/norm(x,y)). The polynomial is of order M in both phi and theta with the form P(phi,M)*P(theta,0) + P(phi, M-1)*P(theta,1) … + P(phi, M-M)*P(theta,M), where P(i, M) is a polynomial over “i” of degree M (float32, [(M + 1) * (M + 2) / 2,])

class ncore.data.CameraLabelDescriptor(
camera_id: str,
label_type: LabelType,
label_schema: LabelSchema,
label_source: LabelSource = None,
)#

Bases: DataClassJsonMixin

Compound descriptor bundling the identity and schema of one camera label instance.

Passed directly to CameraLabelsComponent.Writer to define what it stores. The default_instance_name property provides a recommended naming convention.

camera_id: str#
property default_instance_name: str#

category.qualifier@camera_id.

Type:

Recommended instance name

classmethod from_dict(
kvs: dict | list | str | int | float | bool | None,
*,
infer_missing: bool = False,
) → CameraLabelDescriptor#

Decodes a descriptor like the generic dataclasses-json from_dict, but reuses decoded label types and schemas via label_type_cache / label_schema_cache.

The generic decoder resolves type hints on every call (~0.5 ms per descriptor). Sequences can have one descriptor per camera and label type (e.g., hundreds for per-frame cameras), which typically all share the same label type and schema, so decoding them dominated opening such sequences.

label_schema: LabelSchema#
label_schema_cache: ClassVar[DecodedValueCache[dict | list | str | int | float | bool | None, LabelSchema]] = <ncore.impl.data.util.DecodedValueCache object>#
label_source: LabelSource#
label_type: LabelType#
label_type_cache: ClassVar[DecodedValueCache[dict | list | str | int | float | bool | None, LabelType]] = <ncore.impl.data.util.DecodedValueCache object>#

Caches of decoded label types / schemas used by from_dict(). All label components of a sequence typically share these, and only differ in their camera. max_size can be tuned (None: unbounded, 0: no caching).

class ncore.data.CameraLabelsProtocol(*args, **kwargs)#

Bases: Protocol

Protocol for accessing camera-associated image labels.

Each instance provides labels of one type for one camera, with independently-managed timestamps.

class CameraLabelHandleProtocol(*args, **kwargs)#

Bases: Protocol

Protocol for a single camera label at a specific timestamp.

Returned by CameraLabelsProtocol.get_label() and provides deferred access to the label data and metadata.

property generic_meta_data: JsonDocument#

Per-label generic metadata.

get_data() → npt.NDArray[Any]#

Load and return the label data as a numpy array.

get_encoded_data() → bytes | None#

Return raw encoded bytes for IMAGE_ENCODED labels, or None for RAW labels.

property timestamp_us: int#

Timestamp of this label in microseconds (usually associated with the camera end-of-frame timestamp).

get_label(
timestamp_us: int,
) → CameraLabelHandleProtocol#

Return a lazy handle to the label data at the given timestamp.

property label_descriptor: CameraLabelDescriptor#

Descriptor of this label instance.

property label_timestamps_us: npt.NDArray[np.uint64]#

Timestamps of all stored labels, sorted ascending.

property labels_count: int#

Number of stored labels.

property labels_generic_meta_data: JsonDocument#

Generic metadata associated with all labels.

class ncore.data.CameraModelParameters(
resolution: ndarray = None,
shutter_type: ShutterType = None,
external_distortion_parameters: ExternalDistortionParameters | None = None,
)#

Bases: DataClassJsonMixin, ABC

Represents parameters common to all camera models

The JSON (de)serialization interface (to_dict() / from_dict()) is provided by dataclasses_json.DataClassJsonMixin on this base, so that code operating on the abstract type can serialize parameters without narrowing to a concrete model first.

external_distortion_parameters: ExternalDistortionParameters | None = None#

Optional external distortion source associated to the camera (e.g. windshield). If a source exists, rays will be distorted prior to reaching the camera and its associated lens distortion if applicable

abstractmethod paraxial_pinhole_geometry() → ParaxialPinholeGeometry#

The ideal pinhole agreeing with this model to first order about the optical axis

The single extension point behind IdealPinholeCameraModelParameters.from_source() and IdealPinholeCameraModelParameters.natural_fov(). Implementing it is all a model registered out of tree with ncore.sensors.register_camera_model() needs to be usable by both.

Required rather than defaulted, like transform(), so that a new model has to make a deliberate decision here instead of inheriting a silent refusal. A model with no meaningful paraxial pinhole opts out explicitly by raising TypeError.

Raises:

TypeError – If the concrete model does not define a paraxial pinhole.

resolution: ndarray = None#

Width and height of the image in pixels (uint64, [2,])

shutter_type: ShutterType = None#

Shutter type of the camera’s imaging sensor

abstractmethod transform(
image_domain_scale: float | Tuple[float, float],
image_domain_offset: Tuple[float, float] = (0.0, 0.0),
new_resolution: Tuple[int, int] | None = None,
) → Self#

Applies a transformation to camera model parameter

Parameters:
  • image_domain_scale – an isotropic (if float) or anisotropic (if tuple of floats) scaling of the full image domain to a scaled image domain (e.g., to account for up-/downsampling). Resulting scaled image resolution needs to be integer if no explicit ‘new_resolution’ is provided.

  • image_domain_offset – an offset of the _scaled_ image domain (e.g., to account for cropping).

  • new_resolution – an optional new resolution to set (if None, the full scaled resolution is used).

Returns:

a transformed version of the concrete camera model parameters

abstractmethod static type() → str#

Returns a string-identifier of the camera

Concrete subclasses must provide their own stable identifier; it keys the serialized representation (see encode_camera_model_parameters()) and the deserialization registry.

class ncore.data.CameraSensorProtocol(*args, **kwargs)#

Bases: SensorProtocol, Protocol

CameraSensorProtocol provides unified access to a relevant subset of common NCore camera sensor APIs

class EncodedImageDataHandleProtocol(*args, **kwargs)#

Bases: Protocol

References encoded image data without loading it

get_data() → EncodedImageData#

Loads the referenced encoded image data to memory

get_frame_data(
frame_index: int,
) → EncodedImageData#

Returns the frame’s encoded image data

get_frame_handle(
frame_index: int,
) → EncodedImageDataHandleProtocol#

Returns a handle of the frame’s encoded image data

get_frame_image(
frame_index: int,
) → Image#

Returns the frame’s decoded image data

get_frame_image_array(
frame_index: int,
) → npt.NDArray[np.uint8]#

Returns decoded image data as array [W,H,C]

get_mask_images() → Dict[str, Image]#

Returns all available named camera mask images

property model_parameters: CameraModelParameters#

Returns parameters specific to the camera’s intrinsic model

ncore.data.ConcreteExternalDistortionParametersUnion#

alias of BivariateWindshieldModelParameters

ncore.data.ConcreteLidarModelParametersUnion#

alias of RowOffsetStructuredSpinningLidarModelParameters

class ncore.data.CuboidTrackObservation(
track_id: str,
class_id: str,
timestamp_us: int,
reference_frame_id: str,
reference_frame_timestamp_us: int,
bbox3: BBox3,
source: LabelSource = None,
source_version: str | None = None,
)#

Bases: DataClassJsonMixin

Individual cuboid track observation relative to a reference frame

bbox3: BBox3#

Bounding-box coordinates of the object relative to the reference frame’s coordinate system

class_id: str#

String-representation of the labeled class of the object

reference_frame_id: str#

String-identifier of the reference frame (e.g., sensor name)

reference_frame_timestamp_us: int#

The timestamp of the reference frame

source: LabelSource = None#

The source for the current label

source_version: str | None = None#
timestamp_us: int#

The timestamp associated with the centroid of the observation (possibly an accurate in-frame time)

track_id: str#

Unique identifier of the object’s track this observation is associated with

transform(
target_frame_id: str,
target_frame_timestamp_us: int,
pose_graph: PoseGraphInterpolator,
anchor_frame_id: str = 'world',
) → Self#

Transform the observation’s bounding box to a different reference frame.

Parameters:
  • target_frame_id – ID of the target reference frame

  • target_frame_timestamp_us – Timestamp of the target reference frame

  • pose_graph – PoseGraphInterpolator to perform the evaluation of transformations

  • anchor_frame_id – ID of the common anchor frame for transformations (default: “world”)

Returns:

A CuboidTrackObservation instance with the transformed bounding box and updated reference frame info

class ncore.data.EncodedImageData(encoded_image_data: bytes, encoded_image_format: str)#

Bases: object

Represents encoded image data of a specific format in memory

get_decoded_image() → Image#

Returns decoded image from image data.

The result is memoized per instance. (Using functools.lru_cache on a method is avoided here: it keys the cache on self and keeps a global, process-wide strong reference to the instance, which both leaks memory and survives fork() into DataLoader workers in whatever state it held.)

get_encoded_image_data() → bytes#

Returns encoded image data

get_encoded_image_format() → str#

Returns encoded image format

ncore.data.EncodedImageHandle#

alias of EncodedImageDataHandleProtocol

class ncore.data.ExternalDistortionParameters#

Bases: DataClassJsonMixin, ABC

Represents parameters common to all external distortion models

External distortion is any source of distortion outside the camera itself (e.g. a windshield). The JSON (de)serialization interface (to_dict() / from_dict()) is provided by dataclasses_json.DataClassJsonMixin on this base, so that code operating on the abstract type can serialize parameters without narrowing to a concrete model first.

abstractmethod static type() → str#

Returns a string-identifier of the external

Concrete subclasses must provide their own stable identifier; it keys the serialized representation (see CameraModelParameters.to_dict()) and the deserialization registry.

class ncore.data.FOV(
start_rad: float,
span_rad: float,
direction: Literal['cw', 'ccw'],
)#

Bases: object

Represents a field-of-view with start and span in radians

direction: Literal['cw', 'ccw']#

Direction of the valid field-of-view region, either clockwise or counter-clockwise

span_rad: float#

Span of the valid field-of-view region in radians in [0, 2π]

start_rad: float#

Start angle of the field-of-view in radians

class ncore.data.FThetaCameraModelParameters(
resolution: np.ndarray = None,
shutter_type: ShutterType = None,
external_distortion_parameters: ExternalDistortionParameters | None = None,
principal_point: np.ndarray = None,
reference_poly: PolynomialType = None,
pixeldist_to_angle_poly: np.ndarray = None,
angle_to_pixeldist_poly: np.ndarray = None,
max_angle: float = 0.0,
linear_cde: np.ndarray = <factory>,
tangential_coeffs: np.ndarray = <factory>,
)#

Bases: CameraModelParameters

Represents FTheta-specific camera model parameters

POLYNOMIAL_DEGREE = 6#
class PolynomialType(value)#

Bases: IntEnum

Enumerates different possible polynomial types

ANGLE_TO_PIXELDIST = 2#

Polynomial mapping angles-to-pixeldistances (also known as “forward” polynomial)

PIXELDIST_TO_ANGLE = 1#

Polynomial mapping pixeldistances-to-angles (also known as “backward” polynomial)

angle_to_pixeldist_poly: np.ndarray = None#

Coefficients of the angles-to-pixeldistances polynomial (float32, [6,])

property bw_poly: ndarray#

Alias for the pixeldistances-to-angles polynomial

property fw_poly: ndarray#

Alias for the angles-to-pixeldistances polynomial

property has_linear_term: bool#

Whether the linear term differs from the identity [1, 0, 0]

property has_tangential_distortion: bool#

Whether any tangential distortion coefficient is non-zero

linear_cde: np.ndarray#

Coefficients of the constrained linear term [c,d;e,1] transforming between sensor coordinates (in mm) to image coordinates (in px) (float32, [3,]). The identity [1, 0, 0] (the default) is omitted when serializing

max_angle: float = 0.0#

Maximal extrinsic ray angle [rad] with the principal direction (float32)

paraxial_pinhole_geometry() → ParaxialPinholeGeometry#

First-order term of the angles-to-pixeldistances polynomial, scaled by the linear term

The forward polynomial maps delta = f(theta) = c0 + c1*theta + ..., and r = f*tan(theta) ~= f*theta near theta = 0, so d(delta)/d(theta)|_0 = c1. The linear term contributes a per-axis scale; its shear components d and e are not representable by a pinhole and are dropped. The principal point is stored in the NVIDIA pixel-center convention, so a +0.5 shift brings it into image coordinates.

Raises:

ValueError – If the polynomial does not yield a positive focal length.

pixeldist_to_angle_poly: np.ndarray = None#

Coefficients of the pixeldistances-to-angles polynomial (float32, [6,])

principal_point: np.ndarray = None#

U and v coordinate of the principal point, following the NVIDIA default convention for FTheta camera models in which the pixel indices represent the center of the pixel (not the top-left corners). Principal point coordinates will be adapted internally in camera model APIs to reflect the image coordinate conventions

reference_poly: PolynomialType = None#

Indicating which of the two stored polynomials is the model’s reference polynomial (the other polynomial is only an approximation)

tangential_coeffs: np.ndarray#

Tangential distortion coefficients [t0, t1] in pixels (float32, [2,]). With normalized coordinates x = X/Z, y = Y/Z the offsets du = 2*t0*x*y + t1*(r^2 + 2*x^2) and dv = t0*(r^2 + 2*y^2) + 2*t1*x*y (r^2 = x^2 + y^2) are added to the radial (polynomial) offset from the principal point before the linear term is applied. All zeros (the default) means no tangential distortion; such values are omitted when serializing

transform(
image_domain_scale: float | Tuple[float, float],
image_domain_offset: Tuple[float, float] = (0.0, 0.0),
new_resolution: Tuple[int, int] | None = None,
) → Self#

Applies a transformation to FTheta camera model parameter

Parameters:
  • image_domain_scale – an isotropic (if float) or anisotropic (if tuple of floats) scaling of the full image domain to a scaled image domain (e.g., to account for up-/downsampling). Resulting scaled image resolution needs to be integer if no explicit ‘new_resolution’ is provided.

  • image_domain_offset – an offset of the _scaled_ image domain (e.g., to account for cropping).

  • new_resolution – an optional new resolution to set (if None, the full scaled resolution is used).

Returns:

a transformed version of the FTheta camera model parameters

static type() → str#

Returns a string-identifier of the camera model

class ncore.data.FrameTimepoint(value)#

Bases: IntEnum

Enumerates special timepoints within a frame (values used to index into buffers)

END = 1#

Requested timepoint is referencing the end time of the frame

START = 0#

Requested timepoint is referencing the start time of the frame

class ncore.data.IdealPinholeCameraModelParameters(
resolution: ndarray = None,
shutter_type: ShutterType = None,
external_distortion_parameters: ExternalDistortionParameters | None = None,
principal_point: ndarray = None,
focal_length: ndarray = None,
)#

Bases: PinholeCameraModelParameters

Represents an ideal (distortion-free) pinhole camera

An ideal pinhole maps normalized camera coordinates directly to image coordinates via focal_length and principal_point with no lens distortion. It is the most efficient camera model and the natural target for rectification.

fov() → ndarray#

Per-axis full field-of-view angles [fov_x, fov_y] [rad] of this ideal pinhole

The pinhole maps angle to pixel distance as r = f * tan(theta), so the full field of view to the farthest image border along each axis is 2 * atan(half_extent / focal).

static from_source(
source: CameraModelParameters,
target_fov: float | ndarray | None = None,
) → IdealPinholeCameraModelParameters#

Construct an ideal (distortion-free) pinhole approximating source

The source camera’s paraxial pinhole geometry (focal length, principal point, resolution) is extracted and an ideal pinhole is assembled. The angular extent is controlled by target_fov (full field-of-view angles [rad]):

  • None: use the source’s natural per-axis field of view (natural_fov()).

  • float: an isotropic target full field of view, preserving the source focal-length aspect ratio (the most binding axis lands exactly at this value).

  • np.ndarray [2,]: per-axis target full field of view [fov_x, fov_y]; from_source(source, target_fov=natural_fov(source)) reproduces the default.

target_fov selects which rays the pinhole covers (the angular extent), not a magnification: because a pinhole maps angle to pixel distance as r = f * tan(theta), different values yield genuinely different views (the periphery stretches increasingly for wider fields of view; the optical axis stays fixed). Widening past the source’s captured field of view is allowed and yields invalid (out-of-source) regions when rectifying.

Parameters:
  • source – the source camera model parameters to convert. Supported types are F-Theta, OpenCV pinhole, OpenCV fisheye and ideal pinhole.

  • target_fov – optional target full field-of-view angle(s) [rad] (see above).

Returns:

ideal pinhole camera model parameters approximating source.

Raises:
  • TypeError – if source is of an unsupported camera model type.

  • ValueError – if the resulting field of view cannot be represented by a pinhole (any axis at or beyond 180 degrees), or target_fov is invalid.

static natural_fov(
source: CameraModelParameters,
) → ndarray#

Per-axis full field-of-view angles [fov_x, fov_y] [rad] of source’s ideal pinhole

This is the field of view of the (paraxial) ideal pinhole that from_source() produces by default (target_fov=None). It is the natural value to scale when choosing a target_fov (e.g. 0.8 * natural_fov(source) to narrow, 1.2 * ... to widen). May be >= pi for wide fisheye / omnidirectional cameras, in which case from_source() requires an explicit feasible target_fov.

Parameters:

source – the source camera model parameters to convert.

Returns:

per-axis full field-of-view angles [rad] (float, [2,]).

static type() → str#

Returns a string-identifier of the camera model

class ncore.data.LabelCategory(value)#

Bases: IntEnum

High-level category of a label types.

DEPTH = 0#

Distance measures (z-axis, ray, relative)

FEATURE = 6#

Feature embeddings (DINOv2, CLIP)

FLOW = 1#

Motion displacement fields (optical, scene)

GEOMETRY = 4#

Geometric vectors (normals, ray directions)

MASK = 3#

Binary / multi-level masks

MATERIAL = 5#

Material / surface properties (albedo, roughness)

OTHER = 7#

Catch-all for uncategorised labels

SEGMENTATION = 2#

Classification (semantic, instance, panoptic)

UNKNOWN = -1#

Unrecognised / fallback category (reader-only)

classmethod resolve(
name: str,
) → LabelCategory#

Return the member matching name, or UNKNOWN if unrecognised.

class ncore.data.LabelEncoding(value)#

Bases: IntEnum

Describes how the raw label data is stored on disk.

IMAGE_ENCODED = 1#

Stored as an encoded image (e.g. PNG, JPEG)

RAW = 0#

Stored as a raw numeric array

UNKNOWN = -1#

Unrecognised / fallback encoding (reader-only)

classmethod resolve(
name: str,
) → LabelEncoding#

Return the member matching name, or UNKNOWN if unrecognised.

class ncore.data.LabelSchema(
dtype: dtype = None,
shape_suffix: Tuple[int, ...] = (),
encoding: LabelEncoding = None,
encoded_format: str | None = None,
quantization: QuantizationParams | None = None,
)#

Bases: DataClassJsonMixin

Schema describing the dtype, shape, encoding and quantization of a single label layer.

dtype: dtype#

Numpy dtype of the label data (after decoding / de-quantization)

encoded_format: str | None#
encoding: LabelEncoding#

How the label data is stored on disk

quantization: QuantizationParams | None#

Optional quantization parameters

shape_suffix: Tuple[int, ...]#

Extra dimensions appended to (H, W)

class ncore.data.LabelSource(value)#

Bases: IntEnum

Enumerates different sources for labels (auto, manual, GT, synthetic etc.)

AUTOLABEL = 1#

Label originates from an autolabeling pipeline

EXTERNAL = 2#

Label originates from an unspecified external source, e.g., from third-party processes

GT_ANNOTATION = 4#

Label originates from manual annotation and is considered ground-truth

GT_SYNTHETIC = 3#

Label originates from a synthetic data simulation and is considered ground-truth

UNKNOWN = -1#

Unrecognised / fallback source (reader-only)

classmethod resolve(name: str) → LabelSource#

Return the member matching name, or UNKNOWN if unrecognised.

class ncore.data.LabelType(
category: LabelCategory = None,
qualifier: str = '',
unit: LabelUnit | None = None,
)#

Bases: DataClassJsonMixin

Describes the semantic kind of a label: category + qualifier + unit.

Well-known combinations are exposed as class-level constants (e.g. LabelType.DEPTH_Z_M). Project-specific labels use custom qualifiers with no code changes required.

DEPTH_RAY_M: ClassVar[LabelType] = LabelType(category=<LabelCategory.DEPTH: 0>, qualifier='ray', unit=<LabelUnit.METERS: 0>)#
DEPTH_RELATIVE: ClassVar[LabelType] = LabelType(category=<LabelCategory.DEPTH: 0>, qualifier='relative', unit=<LabelUnit.UNITLESS: 2>)#
DEPTH_Z_M: ClassVar[LabelType] = LabelType(category=<LabelCategory.DEPTH: 0>, qualifier='z', unit=<LabelUnit.METERS: 0>)#
FLOW_OPTICAL_BACKWARD_PX: ClassVar[LabelType] = LabelType(category=<LabelCategory.FLOW: 1>, qualifier='optical_backward', unit=<LabelUnit.PIXELS: 1>)#
FLOW_OPTICAL_FORWARD_PX: ClassVar[LabelType] = LabelType(category=<LabelCategory.FLOW: 1>, qualifier='optical_forward', unit=<LabelUnit.PIXELS: 1>)#
FLOW_SCENE_BACKWARD_M: ClassVar[LabelType] = LabelType(category=<LabelCategory.FLOW: 1>, qualifier='scene_backward', unit=<LabelUnit.METERS: 0>)#
FLOW_SCENE_FORWARD_M: ClassVar[LabelType] = LabelType(category=<LabelCategory.FLOW: 1>, qualifier='scene_forward', unit=<LabelUnit.METERS: 0>)#
GEOMETRY_NORMAL_CAMERA: ClassVar[LabelType] = LabelType(category=<LabelCategory.GEOMETRY: 4>, qualifier='normal_camera', unit=<LabelUnit.UNITLESS: 2>)#
GEOMETRY_NORMAL_WORLD: ClassVar[LabelType] = LabelType(category=<LabelCategory.GEOMETRY: 4>, qualifier='normal_world', unit=<LabelUnit.UNITLESS: 2>)#
GEOMETRY_RAY_DIRECTION: ClassVar[LabelType] = LabelType(category=<LabelCategory.GEOMETRY: 4>, qualifier='ray_direction', unit=<LabelUnit.UNITLESS: 2>)#
MASK_BACKGROUND: ClassVar[LabelType] = LabelType(category=<LabelCategory.MASK: 3>, qualifier='background', unit=<LabelUnit.UNITLESS: 2>)#
MASK_DYNAMIC: ClassVar[LabelType] = LabelType(category=<LabelCategory.MASK: 3>, qualifier='dynamic', unit=<LabelUnit.UNITLESS: 2>)#
SEGMENTATION_INSTANCE: ClassVar[LabelType] = LabelType(category=<LabelCategory.SEGMENTATION: 2>, qualifier='instance', unit=<LabelUnit.UNITLESS: 2>)#
SEGMENTATION_SEMANTIC: ClassVar[LabelType] = LabelType(category=<LabelCategory.SEGMENTATION: 2>, qualifier='semantic', unit=<LabelUnit.UNITLESS: 2>)#
category: LabelCategory#

High-level label family

qualifier: str#

Free-form variant identifier (e.g. “z”, “optical_forward”, “semantic”)

unit: LabelUnit | None#

Physical unit of the label values, if applicable

class ncore.data.LabelUnit(value)#

Bases: IntEnum

Physical unit associated with a label’s numeric values.

METERS = 0#

Meters (metric)

PIXELS = 1#

Pixel displacement

UNITLESS = 2#

Dimensionless quantity (e.g. class IDs, masks)

UNKNOWN = -1#

Unrecognised / fallback unit (reader-only)

classmethod resolve(name: str) → LabelUnit#

Return the member matching name, or UNKNOWN if unrecognised.

class ncore.data.LidarModelParameters#

Bases: DataClassJsonMixin, ABC

Represents parameters common to all lidar models

The JSON (de)serialization interface (to_dict() / from_dict()) is provided by dataclasses_json.DataClassJsonMixin on this base, so that code operating on the abstract type can serialize parameters without narrowing to a concrete model first.

abstractmethod get_horizontal_fov(
dtype: npt.DTypeLike = <class 'numpy.float32'>,
) → util.FOV#

The lidar’s horizontal field of view, in the requested dtype precision

See get_vertical_fov(). A model that spins through a full revolution reports a span of 2 * pi.

abstractmethod get_vertical_fov(
dtype: npt.DTypeLike = <class 'numpy.float32'>,
) → util.FOV#

The lidar’s vertical field of view, in the requested dtype precision

Every lidar has a vertical and a horizontal field of view, whatever its scanning design, so both are declared here rather than on the one concrete model that happens to implement them today. A model derives them from whatever it stores: elevations and azimuths for a structured spinning lidar, something else entirely for a flash or solid-state one.

abstractmethod static type() → str#

Returns a string-identifier of the lidar

Concrete subclasses must provide their own stable identifier; it keys the serialized representation (see encode_lidar_model_parameters()) and the deserialization registry.

class ncore.data.LidarSensorProtocol(*args, **kwargs)#

Bases: RayBundleSensorProtocol, Protocol

LidarSensorProtocol provides unified access to a relevant subset of common NCore lidar sensor APIs

get_frame_ray_bundle_model_element(
frame_index: int,
) → npt.NDArray[np.uint16] | None#

Returns the per-ray model elements for a ray bundle for a specific frame, if available.

Parameters:

frame_index – Index of the frame

Returns:

Array of per-ray model elements [N,] or None if not available

get_frame_ray_bundle_return_intensity(
frame_index: int,
return_index: int = 0,
) → npt.NDArray[np.float32]#

Returns the per-ray measured intensities for a ray bundle return for a specific frame.

Parameters:
  • frame_index – Index of the frame

  • return_index – Index of the ray bundle return to retrieve (for multi-return sensors)

Returns:

Array of per-ray intensities [N,]

property model_parameters: LidarModelParameters | None#

Returns parameters specific to the lidar’s intrinsic model (optional as not mandatory)

class ncore.data.OpenCVFisheyeCameraModelParameters(
resolution: ndarray = None,
shutter_type: ShutterType = None,
external_distortion_parameters: ExternalDistortionParameters | None = None,
principal_point: ndarray = None,
focal_length: ndarray = None,
radial_coeffs: ndarray = None,
max_angle: float = 0.0,
)#

Bases: CameraModelParameters

Represents Fisheye-specific (OpenCV-like) camera model parameters

static compute_max_angle(
resolution: ndarray,
focal_length: ndarray,
principal_point: ndarray,
radial_coeffs: ndarray,
) → float#

Estimate max_angle from the farthest image corner, respecting monotonicity of the forward polynomial.

Finds the largest angle theta such that the OpenCV fisheye forward distortion model

\[r(\theta) = \theta\,(1 + k_1\theta^2 + k_2\theta^4 + k_3\theta^6 + k_4\theta^8)\]

is monotonically increasing (i.e. \(r'(\theta) > 0\)) and \(r(\theta)\) does not exceed the normalised pixel distance of the farthest image corner.

Parameters:
  • resolution (np.ndarray) – Image resolution [width, height] (uint64 or int, [2,]).

  • focal_length (np.ndarray) – Focal lengths [fu, fv] (float32, [2,]).

  • principal_point (np.ndarray) – Principal point [cu, cv] (float32, [2,]).

  • radial_coeffs (np.ndarray) – Fisheye radial distortion coefficients [k1, k2, k3, k4] (float32, [4,]).

Returns:

Maximum angle in radians.

Return type:

float

focal_length: ndarray = None#

Focal lengths in u and v direction, resp., mapping (distorted) normalized camera coordinates to image coordinates relative to the principal point (float32, [2,])

max_angle: float = 0.0#

Maximal extrinsic ray angle [rad] with the principal direction (float32)

paraxial_pinhole_geometry() → ParaxialPinholeGeometry#

The model’s own focal length and principal point, already in image coordinates

principal_point: ndarray = None#

U and v coordinate of the principal point, following the image coordinate conventions (float32, [2,])

radial_coeffs: ndarray = None#

Radial distortion coefficients radial_coeffs represent OpenCV-like [k1,k2,k3,k4] coefficients to parameterize the

transform(
image_domain_scale: float | Tuple[float, float],
image_domain_offset: Tuple[float, float] = (0.0, 0.0),
new_resolution: Tuple[int, int] | None = None,
) → Self#

Applies a transformation to OpenCV fisheye camera model parameter

Parameters:
  • image_domain_scale – an isotropic (if float) or anisotropic (if tuple of floats) scaling of the full image domain to a scaled image domain (e.g., to account for up-/downsampling). Resulting scaled image resolution needs to be integer if no explicit ‘new_resolution’ is provided.

  • image_domain_offset – an offset of the _scaled_ image domain (e.g., to account for cropping).

  • new_resolution – an optional new resolution to set (if None, the full scaled resolution is used).

Returns:

a transformed version of the OpenCV fisheye camera model parameters

static type() → str#

Returns a string-identifier of the camera model

class ncore.data.OpenCVPinholeCameraModelParameters(
resolution: ndarray = None,
shutter_type: ShutterType = None,
external_distortion_parameters: ExternalDistortionParameters | None = None,
principal_point: ndarray = None,
focal_length: ndarray = None,
radial_coeffs: ndarray = None,
tangential_coeffs: ndarray = <factory>,
thin_prism_coeffs: ndarray = <factory>,
)#

Bases: PinholeCameraModelParameters

Represents Pinhole-specific (OpenCV-like) camera model parameters

static compute_max_normalized_radius_squared(
radial_coeffs: ndarray,
) → float#

Computes the largest squared radius of normalized coordinates up to which the radial distortion is valid

With s = r^2 the squared radius of the normalized coordinates (x/z, y/z) and d(s) = N(s) / D(s) the rational radial distortion factor (N(s) = 1 + k1 s + k2 s^2 + k3 s^3, D(s) = 1 + k4 s + k5 s^2 + k6 s^3), the distorted radius r d(s) is a one-to-one function of the radius r up to its first extremum (beyond it, distinct rays project to the same image points). The bound is the smallest positive root of either the derivative of the distorted radius (whose sign is the one of the polynomial N D + 2 s (N' D - N D')) or of D (a pole of the distortion factor), and math.inf if the distortion has neither.

Only the radial distortion is taken into account (tangential and thin-prism distortions are not).

Parameters:

radial_coeffs – the radial distortion coefficients [k1, k2, k3, k4, k5, k6]

Returns:

the exclusive bound on the squared radius of the normalized coordinates of valid camera rays

property has_tangential_distortion: bool#

Whether any tangential distortion coefficient is non-zero

property has_thin_prism_distortion: bool#

Whether any thin-prism distortion coefficient is non-zero

property is_distortion_free: bool#

Whether this OpenCV pinhole is free of any distortion

True iff all radial, tangential and thin-prism coefficients are zero and no external distortion is attached. A distortion-free OpenCV pinhole is equivalent to an ideal pinhole (see IdealPinholeCameraModelParameters.from_source()).

radial_coeffs: ndarray = None#

Radial distortion coefficients [k1,k2,k3,k4,k5,k6] parameterizing the rational radial distortion factor \(\frac{1 + k_1r^2 + k_2r^4 + k_3r^6}{1 + k_4r^2 + k_5r^4 + k_6r^6}\) for squared norms \(r^2\) of normalized camera coordinates (float32, [6,])

tangential_coeffs: ndarray#

Tangential distortion coefficients [p1,p2] parameterizing the tangential distortion components \(\begin{bmatrix} 2p_1x'y' + p_2 \left(r^2 + 2{x'}^2 \right) \\ p_1 \left(r^2 + 2{y'}^2 \right) + 2p_2x'y' \end{bmatrix}\) for normalized camera coordinates \(\begin{bmatrix} x' \\ y' \end{bmatrix}\) (float32, [2,], defaults to zeros if absent; always serialized)

thin_prism_coeffs: ndarray#

Thins prism distortion coefficients [s1,s2,s3,s4] parameterizing the thin prism distortion components \(\begin{bmatrix} s_1r^2 + s_2r^4 \\ s_3r^2 + s_4r^4 \end{bmatrix}\) for squared norms \(r^2\) of normalized camera coordinates (float32, [4,], defaults to zeros if absent; always serialized)

static type() → str#

Returns a string-identifier of the camera model

class ncore.data.ParaxialPinholeGeometry(
focal_length: ndarray,
principal_point: ndarray,
resolution: ndarray,
)#

Bases: object

Geometry of the ideal pinhole that best matches a camera model near the optical axis

The paraxial approximation a model is willing to make of itself: the pinhole agreeing with it to first order about the principal direction. It is what IdealPinholeCameraModelParameters.from_source() builds on, and what IdealPinholeCameraModelParameters.natural_fov() measures.

focal_length: ndarray#

Per-axis focal length [fu, fv] [px] (float32, [2,])

principal_point: ndarray#

Principal point in image coordinates [px] (float32, [2,])

resolution: ndarray#

Image resolution [width, height] [px] (uint64, [2,])

class ncore.data.PointCloud(
_xyz: npt.NDArray[np.floating],
reference_frame_id: str,
reference_frame_timestamp_us: int,
coordinate_unit: PointCloud.CoordinateUnit,
_attributes: Dict[str, PointCloud.Attribute],
_T_raw_reference: npt.NDArray[np.floating] | None = None,
)#

Bases: object

Immutable point cloud with lazy attribute loading and rigid-transform support.

All points share a single reference frame and timestamp (the snapshot timestamp). Per-point timestamps, if available, are stored as a regular INVARIANT attribute.

The transform() method returns a new PointCloud with an accumulated rigid transform stored in _T_raw_reference. The xyz property and covariant attributes apply this transform lazily on access.

class Attribute(
loader: Callable[[], 'npt.NDArray'],
transform_type: PointCloud.AttributeTransformType,
)#

Bases: object

A lazily-loaded point-cloud attribute together with its transform semantics.

loader: Callable[[], 'npt.NDArray']#
transform_type: PointCloud.AttributeTransformType#
class AttributeTransformType(value)#

Bases: IntEnum

How an attribute behaves under a rigid transformation.

DIRECTION = 1#

R @ v (normals, flow directions)

Type:

Rotate only

INVARIANT = 0#

Unchanged (rgb, intensity, confidence, label_id, timestamp_us)

POINT = 2#

R @ p + t (secondary xyz positions)

Type:

Full rigid

class CoordinateUnit(value)#

Bases: IntEnum

Physical unit of the point coordinates.

METERS = 1#

Metric (meters)

UNITLESS = 0#

Arbitrary / unknown scale (e.g. SfM reconstruction)

property attribute_names: List[str]#

Names of all registered attributes.

coordinate_unit: PointCloud.CoordinateUnit#
get_attribute(name: str) → npt.NDArray#

Load and return an attribute, applying the accumulated transform if applicable.

Raises:

KeyError – if name does not refer to a known attribute.

get_attribute_transform_type(
name: str,
) → AttributeTransformType#

Return the AttributeTransformType for name.

Raises:

KeyError – if name does not refer to a known attribute.

has_attribute(name: str) → bool#

Returns True if an attribute with the given name is registered.

property points_count: int#

Number of points in the cloud.

reference_frame_id: str#
reference_frame_timestamp_us: int#
transform(
target_frame_id: str,
target_frame_timestamp_us: int,
pose_graph: PoseGraphInterpolator,
anchor_frame_id: str = 'world',
) → PointCloud#

Transform this point cloud to a different reference frame.

Signature is aligned with CuboidTrackObservation.transform().

The transform is not applied eagerly – it is stored and applied lazily when xyz or get_attribute() are accessed.

Parameters:
  • target_frame_id – ID of the target reference frame.

  • target_frame_timestamp_us – Timestamp of the target reference frame.

  • pose_graph – PoseGraphInterpolator to evaluate transformations.

  • anchor_frame_id – ID of the common anchor frame (default: "world").

Returns:

A new PointCloud with updated reference frame and an accumulated lazy transform.

property xyz: npt.NDArray#

Points in the target reference frame (transform applied lazily).

class ncore.data.PointCloudsSourceProtocol(*args, **kwargs)#

Bases: Protocol

Uniform access to point clouds from any source (native component, lidar, or radar).

A point-clouds source exposes an indexed sequence of PointCloud snapshots, each with its own reference frame and timestamp. Per-pc generic data and metadata are available alongside the typed PointCloud attributes.

get_pc(
pc_index: int,
) → PointCloud#

Return the point cloud at pc_index as an immutable PointCloud instance.

Schema-declared attributes are available via PointCloud.get_attribute().

get_pc_generic_data(
pc_index: int,
name: str,
) → npt.NDArray#

Return a generic data array by name for the given point cloud.

Unlike PointCloud attributes, generic data arrays are not necessarily per-point and do not participate in coordinate-frame transforms.

get_pc_generic_data_names(
pc_index: int,
) → List[str]#

Return the names of all generic data arrays stored for the given point cloud.

get_pc_generic_meta_data(
pc_index: int,
) → JsonDocument#

Returns generic point cloud meta-data for a specific point-cloud.

get_pc_index_range(
start: int | None = None,
stop: int | None = None,
step: int | None = None,
) → range#

Return a range of pc indices following start:stop:step slice conventions.

Absent bounds default to the full [0, pcs_count) range.

has_pc_generic_data(
pc_index: int,
name: str,
) → bool#

Check whether a named generic data array exists for the given point cloud.

property pc_timestamps_us: npt.NDArray[np.uint64]#

Snapshot timestamps in microseconds, shape (pcs_count,).

property pcs_count: int#

Total number of point-cloud snapshots in this source.

property point_clouds_source_id: str#

Unique identifier of this point-clouds source.

class ncore.data.QuantizationParams(
quantized_dtype: dtype = None,
scale: float = 1.0,
offset: float = 0.0,
intermediate_dtype: dtype = dtype('float64'),
)#

Bases: DataClassJsonMixin

Parameters for de-quantizing stored integer data back to physical values.

The physical value is recovered as value = stored * scale + offset.

intermediate_dtype: dtype#

Numpy dtype for intermediate arithmetic during (de-)quantization

offset: float#

Additive offset

quantized_dtype: dtype#

Numpy dtype of the quantized on-disk representation

scale: float#

Multiplicative scale factor

class ncore.data.RadarSensorProtocol(*args, **kwargs)#

Bases: RayBundleSensorProtocol, Protocol

RadarSensorProtocol provides unified access to a relevant subset of common NCore radar sensor APIs

class ncore.data.RayBundleSensorPointCloudsSourceAdapter(
sensor: RayBundleSensorProtocol,
*,
return_index: int = 0,
promote_generic_data: Dict[str,
GenericDataPromotion]={'rgb': RayBundleSensorPointCloudsSourceAdapter.GenericDataPromotion(shape_suffix=(3,
),
transform_type=<AttributeTransformType.INVARIANT: 0>)},
)#

Bases: object

Adapts a RayBundleSensorProtocol (lidar or radar) into PointCloudsSourceProtocol.

Each sensor frame maps to one point cloud. Per-point sensor data (timestamps, valid mask, and – for lidar – intensity and model element) are exposed as lazy PointCloud.Attribute instances. Sensor-level generic_data is forwarded through get_pc_generic_data().

Additionally, generic_data entries listed in promote_generic_data are auto-promoted to PointCloud.Attribute instances when their name matches (case-insensitive). By default, "rgb" with shape (N, 3) is promoted. Shape validation happens lazily on first access (ValueError for mismatching shapes).

The timestamp_us attribute holds the per-ray timestamps read for the motion compensation of the point cloud (if the sensor returns them, see RayBundleSensorProtocol.FramePointCloud.timestamp_us), other attributes are loaded lazily, synchronously, on first access.

Parameters:
DEFAULT_GENERIC_DATA_PROMOTIONS: Dict[str, GenericDataPromotion] = {'rgb': RayBundleSensorPointCloudsSourceAdapter.GenericDataPromotion(shape_suffix=(3,), transform_type=<AttributeTransformType.INVARIANT: 0>)}#
class GenericDataPromotion(
shape_suffix: Tuple[int, ...],
transform_type: AttributeTransformType = AttributeTransformType.INVARIANT,
)#

Bases: object

Shape suffix and transform type for a promoted generic_data frame entry.

Used as the value in the promote_generic_data dict whose keys are the normalised (lowercase) attribute names. Shape validation (N,) + shape_suffix happens lazily on first attribute access.

shape_suffix: Tuple[int, ...]#
transform_type: AttributeTransformType = 0#
get_pc(
pc_index: int,
) → PointCloud#
get_pc_generic_data(
pc_index: int,
name: str,
) → npt.NDArray#
get_pc_generic_data_names(
pc_index: int,
) → List[str]#
get_pc_generic_meta_data(
pc_index: int,
) → JsonDocument#
get_pc_index_range(
start: int | None = None,
stop: int | None = None,
step: int | None = None,
) → range#
has_pc_generic_data(
pc_index: int,
name: str,
) → bool#
property pc_timestamps_us: npt.NDArray[np.uint64]#
property pcs_count: int#
property point_clouds_source_id: str#
class ncore.data.RayBundleSensorProtocol(*args, **kwargs)#

Bases: SensorProtocol, Protocol

RayBundleSensorProtocol provides unified access to a relevant subset of common NCore ray-bundle sensor APIs

class FramePointCloud(
motion_compensation: bool,
xyz_m_start: npt.NDArray[np.floating] | None,
xyz_m_end: npt.NDArray[np.floating],
timestamp_us: npt.NDArray[np.uint64] | None = None,
)#

Bases: object

Container for point cloud data with optional motion compensation

motion_compensation: bool#

Whether coordinates are relative to sensor frame at end-of-frame time (True) or sensor frame at point-time (False)

timestamp_us: npt.NDArray[np.uint64] | None = None#

Per-ray timestamps [N] read for the motion compensation, or None if not read (e.g., without motion compensation)

xyz_m_end: npt.NDArray[np.floating]#

Motion-compensated ray segment end points [N,3]

xyz_m_start: npt.NDArray[np.floating] | None#

Motion-compensated ray segment start points [N,3], or None if not requested

get_frame_point_cloud(
frame_index: int,
motion_compensation: bool,
with_start_points: bool,
return_index: int = 0,
) → FramePointCloud#

Returns a frame-point cloud motion-compensated or non-motion-compensated for a specific frame.

Parameters:
  • frame_index – Index of the frame to retrieve

  • motion_compensation – If True, returns points in sensor frame at end-of-frame time. If False, returns points in sensor frame at point-time

  • with_start_points – If True, include ray segment start points

  • return_index – Index of the point cloud return to retrieve (for multi-return sensors)

Returns:

FramePointCloud containing the point cloud data with requested motion compensation

get_frame_ray_bundle_count(
frame_index: int,
) → int#

Returns the number of rays for a specific frame without decoding it.

Parameters:

frame_index – Index of the frame

Returns:

Number of rays for a specific frame

get_frame_ray_bundle_direction(
frame_index: int,
) → npt.NDArray[np.float32]#

Returns the per-ray directions for the ray-bundle for a specific frame.

Parameters:

frame_index – Index of the frame

Returns:

Array of per-ray directions [N,3]

get_frame_ray_bundle_return_count(
frame_index: int,
) → int#

Returns the number of different ray returns for a specific frame without decoding it.

Parameters:

frame_index – Index of the frame

Returns:

Number of ray returns for a specific frame

get_frame_ray_bundle_return_distance_m(
frame_index: int,
return_index: int = 0,
) → npt.NDArray[np.float32]#

Returns the per-ray measured metric distances for the ray bundle returns of a specific frame.

Parameters:
  • frame_index – Index of the frame

  • return_index – Index of the ray bundle return to retrieve (for multi-return sensors)

Returns:

Array of per-ray metric distances [N,]

get_frame_ray_bundle_return_valid_mask(
frame_index: int,
return_index: int = 0,
) → npt.NDArray[np.bool_]#

Returns the per-ray valid mask for the ray bundle returns of a specific frame.

Parameters:
  • frame_index – Index of the frame

  • return_index – Index of the ray bundle return to retrieve (for multi-return sensors)

Returns:

Array of per-ray return valid masks [N]

get_frame_ray_bundle_timestamp_us(
frame_index: int,
) → npt.NDArray[np.uint64]#

Returns the per-ray timestamps for the ray-bundle for a specific frame.

Parameters:

frame_index – Index of the frame

Returns:

Array of per-ray timestamps [N,]

class ncore.data.ReferencePolynomial(value)#

Bases: IntEnum

Enumerates different possible reference polynomial types

BACKWARD = 2#

The backward polynomial is the reference polynomial, the forward polynomial is its (approximate) inverse

FORWARD = 1#

The forward polynomial is the reference polynomial, the backward polynomial is its (approximate) inverse

class ncore.data.RowOffsetStructuredSpinningLidarModelParameters(
spinning_frequency_hz: float,
spinning_direction: Literal['cw', 'ccw'],
n_rows: int,
n_columns: int,
row_elevations_rad: ndarray = None,
column_azimuths_rad: ndarray = None,
row_azimuth_offsets_rad: ndarray = None,
)#

Bases: StructuredSpinningLidarModelParameters

Represents parameters for a structured spinning lidar model that is using a per-row azimuth-offset (compatible with, e.g., Hesai P128 sensors)

column_azimuths_rad: ndarray = None#
get_horizontal_fov(
dtype: npt.DTypeLike = <class 'numpy.float32'>,
) → util.FOV#

Returns the horizontal field-of-view of the lidar model (starting at first element) in the requested dtype precision

get_vertical_fov(
dtype: npt.DTypeLike = <class 'numpy.float32'>,
) → util.FOV#

Returns the vertical field-of-view of the lidar model (starting at first element) in the requested dtype precision

row_azimuth_offsets_rad: ndarray = None#
row_elevations_rad: ndarray = None#
static type() → str#

Returns a string-identifier of the lidar model

class ncore.data.SensorProtocol(*args, **kwargs)#

Bases: Protocol

SensorProtocol provides unified access to a relevant subset of common NCore sensor data APIs

property frames_count: int#

The number of frames associated with the sensor

property frames_timestamps_us: npt.NDArray[np.uint64]#

The start/end timestamps of the frames associated with the sensor [(N,2) array]

get_T_sensor_rig(
rig_node: str = 'rig',
) → npt.NDArray[np.floating] | None#

Return static extrinsic transformation from sensor to named rig coordinate frame.

Returns the 4x4 homogeneous transformation matrix T_sensor_rig that transforms points from the sensor coordinate frame to the rig coordinate frame.

rig_node defaults to "rig", the well-known name of the rig frame in NCore pose graphs; pass another node name for sequences that name their rig frame differently. For transformations to other frames, or time-dependent ones, use get_frames_T_source_sensor() / get_frames_T_source_target() directly.

Parameters:

rig_node – Name of the rig coordinate frame (default: “rig”)

Returns:

4x4 transformation matrix if the static transformation exists, None otherwise

get_closest_frame_index(
timestamp_us: int,
relative_frame_time: float = 1.0,
) → int#

Given a timestamp, returns the frame index of the closest frame based on the specified relative frame time-point (0.0 ~= start-of-frames / 1.0 ~= end-of-frames)

get_frame_generic_data(
frame_index: int,
name: str,
) → npt.NDArray[Any]#

Returns generic frame-data for a specific frame and name

get_frame_generic_data_names(
frame_index: int,
) → List[str]#

List of all generic frame-data names

get_frame_generic_meta_data(
frame_index: int,
) → JsonDocument#

Returns generic frame meta-data for a specific frame

get_frame_index_range(
start_frame_index: int | None = None,
stop_frame_index: int | None = None,
step_frame_index: int | None = None,
) → range#

Returns a (potentially empty) range of frame indices following start:stop:step slice conventions, defaulting to full frame index range for absent range bound specifiers

get_frame_timestamp_us(
frame_index: int,
frame_timepoint: FrameTimepoint = FrameTimepoint.END,
) → int#

Returns the timestamp of a specific frame at the specified relative frame timepoint (start or end)

get_frames_T_sensor_target(
target_node: str,
frame_indices: int | npt.NDArray[np.integer],
frame_timepoint: FrameTimepoint | None = FrameTimepoint.END,
) → npt.NDArray[np.floating]#

Evaluates relative poses of the sensor at timestamps inferred from frame indices.

Computes transformation matrices T_sensor_target that transform points from the sensor coordinate frame to the target coordinate frame at specified frame times.

Parameters:
  • target_node – Name of the target coordinate frame

  • frame_indices – Individual index or array of frame indices at which to evaluate poses

  • frame_timepoint – Frame-relative timepoint (START or END). If None, returns both

Returns:

Transformation matrices with shape [frame_indices-shape,2,4,4] if frame_timepoint is None (both start and end poses), else [frame_indices-shape,4,4] (single timepoint)

get_frames_T_source_sensor(
source_node: str,
frame_indices: int | npt.NDArray[np.integer],
frame_timepoint: FrameTimepoint | None = FrameTimepoint.END,
) → npt.NDArray[np.floating]#

Evaluates relative sensor-relative poses at timestamps inferred from frame indices.

Computes transformation matrices T_source_sensor that transform points from the source coordinate frame to the sensor coordinate frame at specified frame times.

Parameters:
  • source_node – Name of the source coordinate frame

  • frame_indices – Individual index or array of frame indices at which to evaluate poses

  • frame_timepoint – Frame-relative timepoint (START or END). If None, returns both

Returns:

Transformation matrices with shape [frame_indices-shape,2,4,4] if frame_timepoint is None (both start and end poses), else [frame_indices-shape,4,4] (single timepoint)

get_frames_T_source_target(
source_node: str,
target_node: str,
frame_indices: int | npt.NDArray[np.integer],
frame_timepoint: FrameTimepoint | None = FrameTimepoint.END,
) → npt.NDArray[np.floating]#

Evaluates relative poses at timestamps inferred from frame indices.

Computes transformation matrices T_source_target that transform points from the source coordinate frame to the target coordinate frame at specified frame times.

Parameters:
  • source_node – Name of the source coordinate frame (defaults to sensor_id if None)

  • target_node – Name of the target coordinate frame

  • frame_indices – Individual index or array of frame indices at which to evaluate poses

  • frame_timepoint – Frame-relative timepoint (START or END). If None, returns both

Returns:

Transformation matrices with shape [frame_indices-shape,2,4,4] if frame_timepoint is None (both start and end poses), else [frame_indices-shape,4,4] (single timepoint)

get_frames_timestamps_us(
frame_timepoint: FrameTimepoint = FrameTimepoint.END,
) → npt.NDArray[np.uint64]#

Returns the timestamps of all frames at the specified frame-relative timepoint (start or end) [shape (N,)]

has_frame_generic_data(
frame_index: int,
name: str,
) → bool#

Signals if named generic frame-data exists

property pose_graph: PoseGraphInterpolator#

Access the sensor-associated pose graph (usually the sequence-wide one, unless overwritten)

property sensor_id: str#

The ID of the sensor

set_pose_graph(
pose_graph: PoseGraphInterpolator,
) → None#

Assigns a new pose graph to the sensor instance (e.g., to overwrite / use a sensor-exclusive pose graph)

class ncore.data.SequenceLoaderProtocol(*args, **kwargs)#

Bases: Protocol

SequenceLoaderProtocol provides unified access to a relevant subset of common NCore sequence data APIs

property camera_ids: List[str]#

All camera sensor IDs in the sequence

property camera_labels_ids: List[str]#

List of all camera label instance IDs.

property generic_meta_data: JsonDocument#

Generic meta-data associated with the sequence

get_camera_labels(
camera_label_id: str,
) → CameraLabelsProtocol#

Get a camera label instance by instance ID.

get_camera_sensor(
sensor_id: str,
) → CameraSensorProtocol#

Returns a camera sensor instance for a given sensor id

get_cuboid_track_observations(
timestamp_interval_us: HalfClosedInterval | None = None,
) → Generator[CuboidTrackObservation]#

Returns all available cuboid track observations in the sequence.

Parameters:

timestamp_interval_us – If provided, only observations whose timestamp_us falls within this half-closed interval [start, stop) are returned. When None (default), all observations are returned.

get_lidar_sensor(
sensor_id: str,
) → LidarSensorProtocol#

Returns a lidar sensor instance for a given sensor id

get_point_clouds_source(
source_id: str,
*,
return_index: int = 0,
) → PointCloudsSourceProtocol#

Returns a point-clouds source for a given source id.

For native point-clouds sources, return_index is ignored. For lidar/radar-adapted sources, return_index selects the ray-bundle return.

get_radar_sensor(
sensor_id: str,
) → RadarSensorProtocol#

Returns a radar sensor instance for a given sensor id

get_sequence_meta() → JsonDocument#

Returns sequence-wide meta-data summary as a JSON document (format is instance-dependent, e.g. the dictionary of a SequenceMeta for V4 loaders)

property lidar_ids: List[str]#

All lidar sensor IDs in the sequence

property point_clouds_ids: List[str]#

All native point-clouds source IDs in the sequence

property pose_graph: PoseGraphInterpolator#

The pose graph representing all static and dynamic transformations in the sequence

query_camera_labels(
camera_id: str,
label_type: LabelType | None = None,
label_category: LabelCategory | None = None,
) → Sequence[CameraLabelsProtocol]#

Query camera label instances matching filters.

Parameters:
  • camera_id – Camera ID to match.

  • label_type – If provided, only return sources with this exact label type.

  • label_category – If provided, only return sources whose label type category matches.

property radar_ids: List[str]#

All radar sensor IDs in the sequence

reload_resources() → None#

Reloads any resources used by the internal sequence loader (potentially required for multi-process data loading)

property sequence_id: str#

The unique identifier of the sequence

property sequence_paths: List[UPath]#

List of all dataset paths comprising this sequence (shards / components)

property sequence_timestamp_interval_us: HalfClosedInterval#

The time range of the sequence in microseconds

class ncore.data.ShutterType(value)#

Bases: IntEnum

Enumerates different possible camera imager shutter types

GLOBAL = 5#

Instantaneous global shutter (no rolling shutter)

ROLLING_BOTTOM_TO_TOP = 3#

Rolling shutter from bottom to top of the imager

ROLLING_LEFT_TO_RIGHT = 2#

Rolling shutter from left to right of the imager

ROLLING_RIGHT_TO_LEFT = 4#

Rolling shutter from right to left of the imager

ROLLING_TOP_TO_BOTTOM = 1#

Rolling shutter from top to bottom of the imager

class ncore.data.SpinningLidarModelParameters(
spinning_frequency_hz: float,
spinning_direction: Literal['cw', 'ccw'],
)#

Bases: LidarModelParameters

Represents parameters common to all spinning lidar models

spinning_direction: Literal['cw', 'ccw']#
spinning_frequency_hz: float#
class ncore.data.StructuredSpinningLidarModelParameters(
spinning_frequency_hz: float,
spinning_direction: Literal['cw', 'ccw'],
n_rows: int,
n_columns: int,
)#

Bases: SpinningLidarModelParameters

Represents parameters for a structured spinning lidar model.

A structured lidar model consists of a fixed number of rows x columns point measurements per frame

n_columns: int#
n_rows: int#
ncore.data.register_camera_model_parameters(
parameters_class: Type[CameraModelParametersT],
) → Type[CameraModelParametersT]#

Registers a concrete camera model parameters class for deserialization

Usable as a class decorator. The class is keyed by its type() identifier, which is what the serialized form carries in camera_model_type, so that a model registered out of tree round-trips through decode_camera_model_parameters() as the in-tree ones do.

This is the deserialization counterpart to ncore.sensors.register_camera_model(), which registers the model built from these parameters. A model that is registered but whose parameters are not can be constructed in memory yet not read back from storage.

ncore.data.register_external_distortion_parameters(
parameters_class: Type[ExternalDistortionParametersT],
) → Type[ExternalDistortionParametersT]#

Registers a concrete external distortion parameters class for deserialization

Usable as a class decorator. The class is keyed by its type() identifier, which is what the serialized form carries, so that out-of-tree external distortion parameters round-trip through CameraModelParameters.from_dict() as well as the in-tree ones.

ncore.data.register_lidar_model_parameters(
parameters_class: Type[LidarModelParametersT],
) → Type[LidarModelParametersT]#

Registers a concrete lidar model parameters class for deserialization

The lidar counterpart to register_camera_model_parameters(), keyed by type() and read back by decode_lidar_model_parameters().

JSON Types#

ncore.data.Json#

A JSON value as read (e.g., attributes of nodes): of concrete types, dictionaries and lists. alias of Dict[str, Json] | List[Json] | str | int | float | bool | None

ncore.data.JsonDocument#

A JSON document as read (a dictionary at the top level). alias of Dict[str, Dict[str, Json] | List[Json] | str | int | float | bool | None]

ncore.data.JsonLike#

A JSON-like value to write (e.g., attributes of nodes): of any mappings / sequences of JSON-like values (e.g., read-only mappings, tuples), written as JSON objects / arrays. JSON values are JSON-like. alias of Mapping[str, JsonLike] | Sequence[JsonLike] | str | int | float | bool | None

ncore.data.JsonDocumentLike#

A JSON-like document to write (a mapping at the top level, see JsonLike). alias of Mapping[str, Mapping[str, JsonLike] | Sequence[JsonLike] | str | int | float | bool | None]