Skip to main content

Python SDK for Hand Tracking Streamer telemetry

Project description

Hand Tracking SDK

Python SDK for consuming telemetry from Hand Tracking Streamer (HTS).

Overview

HTS streams UTF-8 CSV lines for wrist pose and hand landmarks.
This SDK provides typed parsing and validation for:

  • wrist packets: 7 floats (x, y, z, qx, qy, qz, qw)
  • landmark packets: 63 floats (21 x [x, y, z])

Streamed joints are in Mediapipe-style 21 landmark points.

[!IMPORTANT] Pre-release: This library is actively under development. Expect breaking changes to come.

Transport API

The SDK includes socket transport primitives for line-based ingestion:

  • UDPLineReceiver
  • TCPServerLineReceiver
  • TCPClientLineReceiver

Network timeout and disconnect behavior is reported through typed exceptions:

  • TransportTimeoutError
  • TransportDisconnectedError
  • TransportClosedError

Frame Assembly API

Use HandFrameAssembler to combine wrist and landmark packets into coherent per-hand frames.

  • Emits a frame only after both components are present for a hand.
  • Ignores stale out-of-order updates (older receive timestamps).
  • Increments sequence_id per hand side on each newly emitted frame.
  • Supports:
    • recv_ts_ns (monotonic receive time)
    • recv_time_unix_ns (optional wall-clock receive time)
    • source_ts_ns (optional upstream timestamp; currently caller-provided)

Coordinate Conversion API

The SDK provides explicit Unity-left-handed to right-handed conversion helpers:

  • unity_left_to_right_position
  • unity_left_to_right_quaternion
  • convert_wrist_pose_unity_left_to_right
  • convert_landmarks_unity_left_to_right
  • convert_hand_frame_unity_left_to_right

Current conversion profile:

  • position: flip Y sign (x, y, z -> x, -y, z)
  • orientation: basis transform equivalent to Y-axis reflection
from hand_tracking_sdk import (
    HandFrameAssembler,
    convert_hand_frame_unity_left_to_right,
)

assembler = HandFrameAssembler()
frame = assembler.push_line("Right wrist:, 0.1, 0.2, 0.3, 0.0, 0.0, 0.0, 1.0")
if frame is not None:
    converted = convert_hand_frame_unity_left_to_right(frame)

Streaming Client API

HTSClient provides a high-level sync stream with filtering and error policy controls.

Key controls:

  • transport mode: udp, tcp_server, tcp_client
  • output mode: packets, frames, both
  • hand filter: left, right, both
  • parse error policy: strict (raise) or tolerant (skip malformed lines)
from hand_tracking_sdk import HTSClient, HTSClientConfig, StreamOutput

client = HTSClient(HTSClientConfig(output=StreamOutput.BOTH))
for event in client.iter_events():
    print(event)

Note: StreamOutput.FRAMES emits only when both wrist and landmarks packets have been received for a hand side. Note: default error_policy is strict; use tolerant to skip malformed lines instead of stopping the stream.

Observability and Error Model

HTSClient exposes structured counters and optional log hooks:

  • get_stats() / reset_stats()
  • ClientStats counters:
    • lines_received, parse_errors, dropped_lines
    • packets_filtered, packets_emitted, frames_emitted
    • callbacks_invoked, callback_errors
  • log_hook in HTSClientConfig receives StreamLogEvent values (LogEventKind)

Additional high-level client exceptions:

  • ClientConfigurationError
  • ClientCallbackError

Core SDK types also include these fields and helpers for further integration:

  • HandFrame.frame_id (explicit frame identifier)
  • timestamps for receive/source tracking:
    • recv_ts_ns
    • recv_time_unix_ns
    • source_ts_ns
  • deterministic serialization helpers:
    • WristPose.to_dict() / WristPose.from_dict()
    • HandLandmarks.to_dict() / HandLandmarks.from_dict()
    • HandFrame.to_dict() / HandFrame.from_dict()

HandFrameAssembler defaults to:

  • left frame id: hts_left_hand
  • right frame id: hts_right_hand

You can override these via frame_id_by_side for middleware-specific naming.

Example

from hand_tracking_sdk import parse_line

packet = parse_line("Right wrist:, 0.1, 0.2, 0.3, 0.0, 0.0, 0.0, 1.0")
print(packet.side, packet.kind, packet.data)

The parser validates packet label, side, and value count, and raises ParseError on malformed input.

Protocol Reference

Documentation

  • Sphinx source lives in docs/
  • Read the Docs build config: .readthedocs.yaml
  • Local build command:
sphinx-build -b html docs docs/_build/html

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hand_tracking_sdk-0.2.0.tar.gz (60.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hand_tracking_sdk-0.2.0-py3-none-any.whl (24.0 kB view details)

Uploaded Python 3

File details

Details for the file hand_tracking_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: hand_tracking_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 60.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.9

File hashes

Hashes for hand_tracking_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 91c3c6486514e355650782e1cfb4b781bd7a2d600608337a746d6fd09b3cd27d
MD5 7fbb69d499a213adbc0e24a0edf9d072
BLAKE2b-256 4a79157881f673d93c47295d1c02ce0ffef942718ccb9394e3eebb4f70cd9944

See more details on using hashes here.

File details

Details for the file hand_tracking_sdk-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hand_tracking_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dcbce77fede395558323674c69a89432d8fddc89f15f986420584d06dd765d14
MD5 11519d73181003282f98072f0749845a
BLAKE2b-256 bd497c700c097638095f749aaff118ce5f3b0706073096bdb000f0c1fe331e9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page