unienv_interface.remote.compression¶
Opt-in lossy compression of server-to-client image arrays.
A client asks for it in hello, e.g. RemoteClient.connect(address,
compress={"image": "jpeg:90"}). The server then encodes the uint8 leaves of
results whose space has metadata["kind"] == "image" (layout "HWC" or
"CHW", 1 or 3 channels; leading dimensions are batch dimensions) with that
codec. Depth maps, float arrays and everything the client sends stay raw.
Codecs are pluggable (:func:unienv_interface.remote.wire.register_codec); the
built-in jpeg codec uses OpenCV when installed, otherwise Pillow.
Classes:
| Name | Description |
|---|---|
JpegCodec |
JPEG per image. Options: |
Functions:
| Name | Description |
|---|---|
parse_spec |
Validate |
compress_result |
Mark the image leaves of a call result for compression (others are returned as is). |
JpegCodec
¶
Bases: ArrayCodec
JPEG per image. Options: quality (1-100), layout (HWC/CHW), format (rgb/bgr/gray).
Methods:
| Name | Description |
|---|---|
encode |
|
decode |
|
parse_spec
¶
Validate {"image": "jpeg:90"} into {"image": ("jpeg", {"quality": 90})}.
compress_result
¶
compress_result(
value: Any,
resource: _Resource,
method: str,
spec: Dict[str, Tuple[str, Dict[str, Any]]],
) -> Any
Mark the image leaves of a call result for compression (others are returned as is).