Files
37duAutomation/libs/desktopauto/desktopauto/cardocr/__init__.py
T
puddy 12ff003249 feat(sdk): hr_sdk 0.2.4 工资卡导入、desktopauto 0.5.0 证件照识别、新增插件 XQ0084
- hr_sdk.wage_import:DrissionPage 注入 cookie 打开 HR 门户,页面内 WS 订阅 + fetch 上传,解析 over: 结果;build_xlsx 第 9 列卡号强制数值(修复「卡号必须是数字」)

- 纯 HTTP 导入不可用:服务端异步任务与浏览器会话强绑定,且前端无轮询接口(已核实),结果通道只能用浏览器上下文

- desktopauto 0.5.0 新增 cardocr:身份证/银行卡 OCR、号码纠错、Luhn 与模 11-2 校验、交叉核对

- 新增插件 XQ0084 银行卡更新EHR系统:AI 表格待处理行 → 影像识别 → 一致性核对/异常名单

- .gitignore 忽略 tests/aitable_probe/_out/(含员工证件照,禁止入库)
2026-11-17 17:48:37 +08:00

53 lines
2.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""身份证 / 银行卡照片识别(纯离线 OCR),供插件直接调用。
能力:
照片 → 卡片定位/透视矫正 → 多遍 OCR → 字段提取 → 身份证校验码 / 银行卡 Luhn 纠错
身份证:号码、姓名、性别、民族、出生、住址、签发机关、有效期
银行卡:卡号、发卡行、有效期、卡类型
批量:按「姓名/图片」目录跑,同人多图合并,自动去重(两列传同一张图)
核对:导出带「待填正确答案」的 Excel;已知号码时做命中分析(一致/高度疑似/部分命中/读不出)
插件里最简单的用法:
from desktopauto import ocr_card, ocr_cards
res = ocr_card(r"D:\\照片\\张三\\银行卡.jpg", expected_name="张三")
print(res["bank_card"]["number"], res["bank_card"]["luhn_ok"], res["flags"])
rows = ocr_cards(r"D:\\照片") # [{folder, id_card, bank_card, flags, ...}]
依赖:opencv-python / numpy / pillow(本库已有)+ rapidocr / onnxruntime(OCR 可选依赖)。
模型随 rapidocr 包内置,纯离线,不联网。
"""
from __future__ import annotations
from .match import check_person, check_persons
from .pipeline import analyze_folder, analyze_image
__version__ = "0.4.1"
__all__ = [
"analyze_image", "analyze_folder",
"check_person", "check_persons",
"write_review_workbook", "verify_workbook",
"__version__",
]
def write_review_workbook(persons, path, source_root: str = "") -> str:
"""导出带「待填正确答案」列的核对工作簿(需要 openpyxl)。"""
try:
from .review import write_review_workbook as _impl # noqa: PLC0415
except ImportError as e: # pragma: no cover
raise RuntimeError("需要 openpyxl 才能导出核对工作簿:pip install openpyxl") from e
return _impl(persons, path, source_root=source_root)
def verify_workbook(path: str) -> dict:
"""回读人工填好的核对工作簿,统计识别准确率(需要 openpyxl)。"""
try:
from .review import verify_workbook as _impl # noqa: PLC0415
except ImportError as e: # pragma: no cover
raise RuntimeError("需要 openpyxl 才能回读核对工作簿:pip install openpyxl") from e
return _impl(path)