Metadata-Version: 2.4
Name: wx_paper_parser
Version: 1.1.60
Summary: Answer sheet ID recognition
Author: asan
License: GPL-3.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Requires-Dist: opencv-python>=4.8
Requires-Dist: numpy>=2.2.6
Requires-Dist: onnxruntime>=1.23.2
Requires-Dist: pyyaml>=6.0
Requires-Dist: zxing-cpp>=3.0
Requires-Dist: shapely>=2.0
Requires-Dist: Pillow>=10.0
Requires-Dist: openai>=2.0.0
Requires-Dist: socksio>=1.0.0
Requires-Dist: colorlog>=6.8
Requires-Dist: alibabacloud-oss-v2
Requires-Dist: cryptography>=42.0

# wx_paper_parser

> Answer-sheet student-ID recognition library — barcode / QR + handwritten bubble filling, with CNN OCR fallback.

答题卡学号识别库。从扫描或拍摄的答题卡图像中识别考号（条码 / 二维码 + 手写填涂）。

## 识别流程

入口 `EnhanceIdExtractor` 按速度优先依次处理：

```
条码 / 二维码 → CNN 检测 → student_id 模型 + 原填涂识别器 + OCR → 遗留识别器
```

- **条码 / 二维码**：最快，命中即返回
- **student_id 模型**：在纵向或横向填涂区内识别学号，结果优先进入候选串
- **原填涂识别器 + 手写 OCR**：继续并行生成兼容候选
- **遗留识别器**：兼容旧版填涂式布局

`RecognitionResult` 使用 `mdl_sid`、`cv_sid`、`ocr_sid` 分别保留
student_id 模型、原填涂识别器和 OCR 的结果；`sid` 是按优先级拼接后的最终候选串。

## 安装

```bash
pip install wx_paper_parser
```

## 依赖

安装时自动拉取：`opencv-python`、`numpy`、`onnxruntime`、`pyyaml`、`zxing-cpp`、`shapely`。

要求 Python ≥ 3.10。

## 用法

```python
import cv2
from wx_paper_parser import EnhanceIdExtractor

extractor = EnhanceIdExtractor()                     # 默认使用包内模型，懒加载
img = cv2.imread("answer_sheet.jpg")

angle, corrected = extractor.correct_direction(img)  # 校正纸张方向
student_id = extractor.read_code(corrected)          # 识别学号
print(student_id)
```

## 主要模块

| 名称 | 说明 |
| --- | --- |
| `EnhanceIdExtractor` | 识别入口，按速度优先 fallback |
| `read_barcode` | 条码 / 二维码读取 |
| `CNNIdRecognizer` | CNN 检测 + OCR 管线 |
| `student_id.StudentIdReader` | 两级 ONNX 填涂学号识别 |
| `CompositionIdRecognizer` | 遗留识别器 |

完整导出见 `wx_paper_parser/__init__.py`。

## 气泡填涂分类器

选择题与遗留填涂式学号共用版本化的 `bubble_classifier`。当前默认运行 V3，并保留 `legacy` / `v2` 一键回退；训练、人工复核和盲测位于相邻独立工程 `bubble_classifier_v2`。详见[气泡填涂分类器 V3：接入说明与使用教程](docs/气泡填涂分类器V3_接入与使用.md)。

## License

GPL-3.0
