# SPDX-License-Identifier: Apache-2.0 """Input decoding and output encoding shared by the Python API and the HTTP server of meteor-p150. The implementation is the vendored ``ttaw.io`` (C08): point clouds (``bin`` / ``npy`` / ``npz`` / ``pcd`` / ``list``), images, cameras + calibration, transforms, named arrays and the output encoders; numpy only, data parsing only, and every client mistake raises :class:`InputError`, which the server maps to HTTP 400. This module re-exports it with the Autoware input layout of this model bound as the default point fields, so ``model(points)`` and ``POST /predict`` decode the same bytes into the same array. """ from __future__ import annotations from typing import Any, Mapping, Optional, Sequence from .ttaw import io as _io from .ttaw.io import * # noqa: F401,F403 (the decoders and encoders: ttaw/API.md section 9) from .ttaw.io import MAX_POINTS_DEFAULT, PointCloud __all__ = list(_io.__all__) # the same public names; the three below are rebound to this model's layout DEFAULT_POINT_FIELDS = tuple(["x", "y", "z", "intensity"]) # the Autoware input layout of this model def decode_points(spec: Mapping[str, Any], *, max_points: int = MAX_POINTS_DEFAULT, max_bytes: Optional[int] = None, default_fields: Sequence[str] = DEFAULT_POINT_FIELDS) -> PointCloud: """The ``points`` envelope of ``/predict`` -> :class:`PointCloud` (``ttaw.io.decode_points`` with this model's default fields).""" return _io.decode_points(spec, max_points=max_points, max_bytes=max_bytes, default_fields=default_fields) def load_points(source: Any, *, fields: Optional[Sequence[str]] = None, fmt: Optional[str] = None, frame_id: str = "base_link", default_fields: Sequence[str] = DEFAULT_POINT_FIELDS) -> PointCloud: """Python-API point input (path, bytes + ``fmt``, (N, C) array or tensor, structured array, envelope, :class:`PointCloud`) -> :class:`PointCloud` (``ttaw.io.load_points`` with this model's default fields).""" return _io.load_points(source, fields=fields, fmt=fmt, frame_id=frame_id, default_fields=default_fields)