52 lines
1.7 KiB
Markdown
52 lines
1.7 KiB
Markdown
使用说明
|
||
|
||
1. 安装依赖:
|
||
```powershell
|
||
pip install -r requirements.txt
|
||
```
|
||
2. 启动 Tk 测试界面:
|
||
```powershell
|
||
python -m app.ui.tk_app
|
||
```
|
||
3. 在界面中点击“选择图片”,然后点击“识别 EAN-13”。
|
||
|
||
摄像头识别
|
||
1. 在 Tk 界面点击“摄像头识别”,程序会打开默认摄像头(`config/config.yaml` 可配置 index、分辨率与轮询间隔)。
|
||
2. 一旦识别到任意条码(优先 EAN‑13),会自动关闭摄像头并在界面显示结果。
|
||
3. 再次点击“停止摄像头”可手动关闭。
|
||
|
||
HTTP 服务(上传识别)
|
||
1. 启动服务:
|
||
```powershell
|
||
python -m app.server.main
|
||
```
|
||
2. PowerShell 上传示例:
|
||
```powershell
|
||
Invoke-RestMethod -Uri http://127.0.0.1:8000/recognize/ean13 -Method Post -Form @{ file = Get-Item .\sample.jpg }
|
||
```
|
||
3. 响应:
|
||
```json
|
||
{ "code": "6901234567892", "type": "EAN13", "others": [{ "type": "CODE128", "code": "..." }], "message": "ok" }
|
||
```
|
||
|
||
配置说明
|
||
- 编辑 `config/config.yaml` 可调整预处理、ROI 过滤、解码参数;字体路径已按系统自动选择。
|
||
- `app.server` 中的 `host/port/max_upload_mb` 控制 HTTP 服务监听与上传大小限制。
|
||
|
||
注意事项
|
||
- 该程序不会自动启动摄像头或后台任务,均需用户手动触发。
|
||
- 若图片分辨率过低或条码倾斜严重,识别率会下降,可增大 `warp_target_height` 与 `sample_rows` 数量。
|
||
|
||
Pyzbar/ZBar 安装说明
|
||
- Windows: 直接 `pip install pyzbar` 即可(已包含 zbar DLL)。
|
||
- macOS: 安装 zbar 库后再安装 pyzbar:
|
||
```bash
|
||
brew install zbar; pip install pyzbar
|
||
```
|
||
- Linux (Debian/Ubuntu):
|
||
```bash
|
||
sudo apt-get update; sudo apt-get install -y libzbar0; pip install pyzbar
|
||
```
|
||
|
||
|