# PLT 裁片处理微服务 独立 FastAPI 服务,用于解析 PLT 并输出按尺码分组的裁片 PNG(Base64)。 ## 1. 启动方式 ```bash cd PltService pip install -r requirements.txt python main.py ``` 默认监听:`http://localhost:8080` 可通过环境变量 `PORT` 修改端口。 ## 2. Docker 运行 ```bash cd PltService docker build -t plt-service:latest . docker run -p 8080:8080 plt-service:latest ``` ## 3. API ### 3.1 健康检查 - `GET /health` ### 3.2 PLT 处理 - `POST /process` - `Content-Type: multipart/form-data` 参数: - `file`:PLT 文件 - `size_labels`:JSON 字符串(如 `["S","M","L","XL"]`) - `dpi`:图片 DPI,默认 `150` - `rotation`:旋转角度,支持 `0/90/-90/180` 返回: - `success` - `total_groups` - `groups[]`(每组包含各尺码裁片的 Base64 图像和坐标信息) ## 4. 依赖 见 `requirements.txt`,核心包括: - `fastapi` / `uvicorn` - `opencv-python-headless` - `shapely` - `scipy` - `Pillow` ## 5. 部署备注 - 可直接镜像化部署到 SAE/K8s/云主机。 - 生产建议限制上传文件大小,并在网关层增加鉴权与限流。