Skip to main content

TouchGlove SDK

High-performance Python SDK for Touch Glove 5-channel tactile data acquisition, RTC time synchronization, real-time 3D displacement/force physical inference (ONNX Runtime / OpenVINO), and H.265 video recording with microsecond-level timestamps.

Powered by a native Rust core with high-efficiency PyO3 bindings.


⚡ Quick Start

Installation

pip install imprintx

Basic Streaming Example

from imprintx import TouchGlove, list_ports
import time

# Scan for available serial ports
ports = list_ports()
print("Available ports:", ports)

if not ports:
    raise RuntimeError("No serial ports found!")

# Connect to glove device and start streaming
with TouchGlove(port=ports[0]) as glove:
    print("Device SN:", glove.get_sn())
    glove.sync_rtc()  # Synchronize host clock with hardware RTC
    glove.start()

    print("Streaming tactile data... Press Ctrl+C to stop.")
    while True:
        batch = glove.poll()
        for frame in batch:
            print(f"Ch {frame.channel} | Seq: {frame.seq_id} | Timestamp: {frame.timestamp_us} us | Image: {frame.image.shape}")
        time.sleep(0.01)

✨ Features

  • High-Throughput 5-Channel Streaming: Concurrent acquisition of 192x192 8-bit tactile images across 5 channels.
  • Hardware RTC Synchronization: Precision clock alignment between host OS and glove hardware RTC.
  • Real-Time Physical Inference: ONNX Runtime and OpenVINO inference for 3D displacement fields (32, 32, 3) and 3D force fields (32, 32, 3) with auto baseline calibration.
  • H.265 Video Recording & Microsecond Timestamps: High-efficiency HEVC grid video encoding + microsecond timestamp JSON export.
  • Cross-Platform Support: Native binaries for Linux (x86_64, aarch64), Windows, and macOS.

📖 Key Python APIs

1. TouchGlove Class

Main interface for device management, data acquisition, and inference.

glove = TouchGlove(
    port="/dev/ttyACM0",     # Serial port path
    model="dense_3ch.onnx", # Path to ONNX model (optional)
    device="auto",           # "auto", "cuda", "gpu", "npu", "cpu", "mac"
    auto_open=True           # Auto handshake on initialization
)

Methods

  • Device Management:

    • glove.open(port: str) / glove.close(): Manage serial connection.
    • glove.start() / glove.stop(): Start / stop tactile data stream.
    • glove.poll() -> FrameBatch: Fetch latest batch of 5-channel tactile frames.
    • glove.is_open() -> bool / glove.is_streaming() -> bool: Query connection status.
  • Baseline Calibration & Inference:

    • glove.calibrate_baseline(duration_sec=1.0): Capture baseline and calibrate zero point for live inference.
    • glove.get_dense_fields(): Get latest 5-channel 3D displacement and force fields (5, 32, 32, 3).
  • Hardware SN & RTC:

    • glove.get_sn() -> str: Query hardware serial number (SN).
    • glove.set_sn(sn: str) -> bool: Write hardware serial number.
    • glove.sync_rtc() -> bool: Sync host OS system time to glove RTC.
    • glove.query_rtc() -> Optional[str]: Query current glove RTC timestamp string.
  • Video Recording:

    • glove.start_recording(output_path, fps=30.0, crf=18): Record 5-channel grid H.265 video.
    • glove.stop_recording() -> str: Stop recording and generate microsecond timestamp JSON file.

2. Frame Class

Represents a single frame from one channel.

  • frame.channel: Channel index (0–4).
  • frame.sensor_id: Hexadecimal sensor hardware ID.
  • frame.seq_id: Frame sequence number.
  • frame.timestamp_us: Hardware reception timestamp in microseconds.
  • frame.image: Raw tactile image as numpy.ndarray (shape=(192, 192), dtype=uint8).
  • frame.disp: Inferred 3D displacement field (shape=(32, 32, 3), dtype=float32, optional).
  • frame.force_field: Inferred 3D force field (shape=(32, 32, 3), dtype=float32, optional).

3. FrameBatch Class

Synchronized batch containing frames across all 5 channels.

  • batch.frames: List of 5 Frame objects (or None for inactive channels).
  • batch.timestamp: Host Unix timestamp (seconds).
  • batch.total_frames: Count of valid frames in batch.
  • Supports iteration: for frame in batch: ...

🛠 Advanced Examples

Model Inference with Baseline Calibration

from imprintx import TouchGlove, list_ports
import time

ports = list_ports()
with TouchGlove(port=ports[0], model="dense_3ch.onnx", device="cuda") as glove:
    glove.start()
    
    print("Calibrating baseline for 1 second...")
    glove.calibrate_baseline(duration_sec=1.0)
    print("Calibration complete!")
    
    while True:
        batch = glove.poll()
        for frame in batch:
            if frame.disp is not None and frame.force_field is not None:
                print(f"Ch {frame.channel} Max Force: {frame.force_field.max():.2f}")
        time.sleep(0.01)

Video Recording & Timestamp Query

from imprintx import TouchGlove, list_ports, load_video_timestamps
import time

ports = list_ports()
with TouchGlove(port=ports[0]) as glove:
    glove.start()
    glove.start_recording("tactile_recording.mp4", fps=30)
    time.sleep(5.0)  # Record 5 seconds
    glove.stop_recording()

# Parse exported microsecond timestamps
records = load_video_timestamps("tactile_recording.mp4.json")
print(f"Total recorded frames: {len(records)}")

Metadata

Release files for imprintx 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for imprintx 0.2.0
File Size Uploaded Provenance Actions
imprintx-0.2.0.tar.gz 65.6 kB Without provenance Details for imprintx-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for imprintx 0.2.0
File Interpreter ABI Platform Actions
imprintx-0.2.0-cp38-abi3-manylinux_2_34_x86_64.whl CPython 3.8 abi3 Linux glibc 2.34+ x86-64 Details for imprintx-0.2.0-cp38-abi3-manylinux_2_34_x86_64.whl

Total release size: 57.3 MB

Release files / imprintx-0.2.0.tar.gz

Download URL imprintx-0.2.0.tar.gz
Size 65.6 kB
Tags Source
SHA-256 checksum
How to use checksums
390ce32c0725d3ba1a5720bc85f89fc836abf618b3f9df741f425432f0ffabd5
BLAKE2b-256 checksum
How to use checksums
511ff1a2ae436eaf4d9fda2751e7d51d1bafe072d19278f2fb76c31cd8004140
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release files / imprintx-0.2.0-cp38-abi3-manylinux_2_34_x86_64.whl

Download URL imprintx-0.2.0-cp38-abi3-manylinux_2_34_x86_64.whl
Size 57.2 MB
Tags CPython 3.8 Linux glibc 2.34+ x86-64 abi3
SHA-256 checksum
How to use checksums
4abed691aa2b9622b4ae528bd8f88ecd8eee7319f952ef047f8424e416ffb6b9
BLAKE2b-256 checksum
How to use checksums
a3fbd58f58826efcd15dd611d97d15800449ef09646b82ee7db5dabe17eb2774
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Security for imprintx 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page