Metadata-Version: 2.4
Name: hdi
Version: 0.1.1
Summary: Small Python consumer for HDI SignalR ZED body frames.
Project-URL: Homepage, https://github.com/MR-HSI/MR-HSI-Python
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: aiohttp<4,>=3.9
Provides-Extra: dev
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"

# HDI Python

一个很小的 Python 消费端包，用来连接本机或局域网内正在运行的 MR-HSI SignalR Server，并订阅 ZED 端转发出来的人体 body 帧数据。

它只消费 `ZedHub` 的 `ZedFrameReceived` 数据，不读取共享内存，也不包含图片帧。

## 安装

推荐安装：

```powershell
python -m pip install https://hdi.iridescent.space/python/latest.tar.gz
```

`hdi.wiki` 备案完成并恢复外层反向代理后，也可以使用：

```powershell
python -m pip install https://python.hdi.wiki/latest.tar.gz
```

在本仓库内开发安装：

```powershell
python -m pip install -e .
```

## 发布流程

版本号只在 `pyproject.toml` 里维护。发布新版本时先递增 `version`，然后运行：

```powershell
.\scripts\Publish-HdiPackage.ps1
```

脚本会运行 `ruff`、构建 sdist/wheel、把不可变版本文件复制到 `MR-HSI-Server/UpdateServer/python/packages/`，并更新 `latest.tar.gz` / `latest.whl` 两个安装入口。不要覆盖已经发布过的 `hdi-x.y.z.*` 文件；需要修复时发布新的 patch 版本。

## 最简单用法

```python
from hdi import run_zed_consumer


def on_frame(frame):
    print(frame.timestamp, frame.body_count)


run_zed_consumer(on_frame)
```

默认会通过 UDP 自动发现本机或局域网内的 SignalR Server，然后连接 `/hub/zed` 并订阅 ZED body 帧。

## 异步用法

```python
import asyncio
from hdi import ZedClient


async def main():
    async with ZedClient() as client:
        async for frame in client.frames():
            print(frame.timestamp, frame.body_count)


asyncio.run(main())
```
