Skip to content

Commit 4cea52e

Browse files
caishilongclaude
andcommitted
refactor: 重命名包名为 svision 并修复代码问题
## 主要变更 - 包名: supervision → svision(避免 PyPI 命名冲突) - 目录重命名: supervision/ → svision/ ## 代码质量 - 运行 ruff --fix 自动修复所有代码问题 - 修复未使用的导入 - 修复 f-string 语法 - 修复异常处理语法 ## 文档更新 - 更新 README.md 中的 PyPI 安装命令 - 更新所有示例代码的导入语句 - 更新 RELEASE_PLAN.md 中的包名引用 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 6e2e75a commit 4cea52e

31 files changed

Lines changed: 117 additions & 876 deletions

AGENTS.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
- 仓库类型: Python 图像识别 + OCR 模块
66
- 运行环境: Python 3.12 (见 `pyproject.toml`)
77
- 依赖管理: `pyproject.toml` (使用 uv)
8-
- 主要模块: `supervision/aircv`, `supervision/orc`, `supervision/options`
8+
- 主要模块: `svision/aircv`, `svision/orc`, `svision/options`
99

1010
## 本仓库显式规则
1111
- 未发现 Cursor 规则: `.cursor/rules/``.cursorrules`
@@ -31,29 +31,29 @@
3131
- `uv run pytest`
3232
- `uv run pytest test`
3333
- 单个测试文件:
34-
- `uv run pytest test/test_supervision.py`
34+
- `uv run pytest test/test_svision.py`
3535
- 按关键字筛选 (pytest 适用):
3636
- `uv run pytest -k ocr`
3737
- 说明:
38-
- `test/test_supervision.py``test/simple_test.py` 主要是脚本式测试
38+
- `test/test_svision.py``test/simple_test.py` 主要是脚本式测试
3939
- 若 pytest 未收集到测试,可直接运行脚本:
4040
- `uv run python test/simple_test.py`
41-
- `uv run python test/test_supervision.py`
41+
- `uv run python test/test_svision.py`
4242

4343
## Lint / 代码质量
4444
- CI workflow 使用命令 (当前仓库未提供根目录 Makefile):
4545
- `make check_code_quality`
4646
- 如需本地 lint,建议临时安装并运行:
4747
- `uv pip install flake8`
48-
- `uv run python -m flake8 supervision test`
48+
- `uv run python -m flake8 svision test`
4949
- 若新增 lint 规则,请同步更新本文件
5050

5151
## 代码结构约定
52-
- 包入口: `supervision/__init__.py`
53-
- 识别核心: `supervision/aircv/*.py`
54-
- OCR 核心: `supervision/orc/__init__.py`
55-
- 全局配置: `supervision/options/__init__.py`
56-
- 工具模块: `supervision/utils/*.py`
52+
- 包入口: `svision/__init__.py`
53+
- 识别核心: `svision/aircv/*.py`
54+
- OCR 核心: `svision/orc/__init__.py`
55+
- 全局配置: `svision/options/__init__.py`
56+
- 工具模块: `svision/utils/*.py`
5757
- 测试资源: `test/assets`, 输出: `test/output`
5858

5959
## 代码风格与约定
@@ -66,8 +66,8 @@
6666
- 私有/内部方法: 前缀 `_`
6767
- 导入顺序:
6868
- 标准库 -> 第三方 -> 本地模块
69-
- 示例: `import os` / `import numpy as np` / `from supervision...`
70-
- 重复依赖: 优先复用已有工具类 (如 `supervision.utils.logger`)
69+
- 示例: `import os` / `import numpy as np` / `from svision...`
70+
- 重复依赖: 优先复用已有工具类 (如 `svision.utils.logger`)
7171

7272
## 格式化与排版
7373
- 未见自动格式化配置 (black/ruff/isort)
@@ -83,7 +83,7 @@
8383
- 内部实现可简化,保持一致即可
8484

8585
## 日志与错误处理
86-
- 统一使用 `supervision.utils.logger` 输出日志
86+
- 统一使用 `svision.utils.logger` 输出日志
8787
- 关键路径记录 `info`,异常用 `warning`/`error`
8888
- 常见策略:
8989
- 输入不合法时返回 `None`
@@ -110,7 +110,7 @@
110110
- 选择性关闭角度分类器以提升速度
111111

112112
## 变更注意事项
113-
- 修改 API 导出时同步更新 `supervision/__init__.py`
113+
- 修改 API 导出时同步更新 `svision/__init__.py`
114114
- 修改 OCR/CV 策略时注意 `Settings`/`Options` 的默认值
115115
- 若新增依赖:
116116
- 更新 `pyproject.toml` 中的 `dependencies``project.optional-dependencies`
@@ -123,8 +123,8 @@
123123

124124
## 常见入口速查
125125
- 快速定位模板:
126-
- `from supervision import find_location`
126+
- `from svision import find_location`
127127
- OCR 识别:
128-
- `from supervision import recognize_text, find_text_position`
128+
- `from svision import recognize_text, find_text_position`
129129
- 统一配置:
130-
- `from supervision.options import Options`
130+
- `from svision.options import Options`

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Supervision - 图像识别与文字识别模块
22

3-
[![PyPI version](https://badge.fury.io/py/supervision.svg)](https://badge.fury.io/py/supervision)
3+
[![PyPI version](https://badge.fury.io/py/svision.svg)](https://badge.fury.io/py/svision)
44

55
一个轻量级、高效的图像识别与文字识别模块。完全独立,无需任何设备连接,可轻松集成到任何项目中(桌面端、Web、移动端等)。
66

@@ -24,15 +24,15 @@
2424
### 从 PyPI 安装(推荐)
2525

2626
```bash
27-
pip install supervision
27+
pip install svision
2828
```
2929

3030
### 从源码安装(开发模式)
3131

3232
```bash
3333
# 克隆仓库
34-
git clone https://github.com/SolidQA/supervision.git
35-
cd supervision
34+
git clone https://github.com/SolidQA/svision.git
35+
cd svision
3636

3737
# 使用 uv 安装(推荐)
3838
uv sync --dev
@@ -46,7 +46,7 @@ pip install -e .
4646
### 图像识别
4747

4848
```python
49-
from supervision import find_location, Template
49+
from svision import find_location, Template
5050
import cv2
5151

5252
# 读取截图
@@ -57,15 +57,15 @@ position = find_location(screenshot, 'button.png', threshold=0.8)
5757
print(position) # (100, 200)
5858

5959
# 方式2: 使用Template
60-
from supervision.aircv.cv import match_loop
60+
from svision.aircv.cv import match_loop
6161
template = Template('button.png')
6262
position = match_loop(lambda: screenshot, template.filepath, threshold=0.8)
6363
```
6464

6565
### 文字识别
6666

6767
```python
68-
from supervision import recognize_text, find_text_position
68+
from svision import recognize_text, find_text_position
6969
import cv2
7070

7171
# 读取图像
@@ -88,7 +88,7 @@ print(position) # (150, 250)
8888
全局配置管理:
8989

9090
```python
91-
from supervision.options import Options, Config
91+
from svision.options import Options, Config
9292

9393
# 设置识别阈值
9494
Options.CV_THRESHOLD = 0.85
@@ -108,8 +108,8 @@ config_dict = Options.get_config_dict()
108108
图像识别功能:
109109

110110
```python
111-
from supervision.aircv.cv import Template, match_loop, multi_find_location
112-
from supervision.aircv.settings import Settings
111+
from svision.aircv.cv import Template, match_loop, multi_find_location
112+
from svision.aircv.settings import Settings
113113

114114
# 配置匹配策略
115115
Settings.CVSTRATEGY = ('tpl', 'kaze', 'brisk')
@@ -129,7 +129,7 @@ positions = multi_find_location(screenshot_func, 'button.png', threshold=0.8)
129129
文字识别功能:
130130

131131
```python
132-
from supervision.orc import TextRecognizer, recognize_text
132+
from svision.orc import TextRecognizer, recognize_text
133133
import cv2
134134

135135
# 创建识别器
@@ -152,7 +152,7 @@ text = recognizer.get_page_text(image)
152152

153153
```python
154154
import cv2
155-
from supervision import find_location
155+
from svision import find_location
156156

157157
def find_button_on_desktop(button_template):
158158
import pyautogui
@@ -180,7 +180,7 @@ find_button_on_desktop('button.png')
180180

181181
```python
182182
from flask import Flask, request, jsonify
183-
from supervision import find_location
183+
from svision import find_location
184184
import cv2
185185
import numpy as np
186186

@@ -207,7 +207,7 @@ def recognize():
207207
### 集成到移动应用自动化
208208

209209
```python
210-
from supervision import find_location, find_text_position
210+
from svision import find_location, find_text_position
211211
import cv2
212212

213213
class MobileAutomation:
@@ -229,7 +229,7 @@ class MobileAutomation:
229229
### 1. 选择合适的算法
230230

231231
```python
232-
from supervision.aircv.settings import Settings
232+
from svision.aircv.settings import Settings
233233

234234
# 快速匹配(简单场景)
235235
Settings.CVSTRATEGY = ('tpl',)
@@ -276,7 +276,7 @@ A:
276276

277277
A:
278278
```python
279-
from supervision.aircv.settings import Settings
279+
from svision.aircv.settings import Settings
280280

281281
# 使用多尺度模板匹配
282282
Settings.CVSTRATEGY = ('gmstpl', 'sift')
@@ -293,7 +293,7 @@ A:
293293
## 项目结构
294294

295295
```
296-
supervision/
296+
svision/
297297
├── options/ # 配置管理模块
298298
│ └── __init__.py
299299
├── aircv/ # 图像识别模块

0 commit comments

Comments
 (0)