Files
ctbjrj/pdfbt/.zcode/plans/plan-sess_102a5996-c0fe-48a9-b058-69b91506b2b8.md
T

29 lines
1.7 KiB
Markdown
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.
# 新增 UApiPro(uapis.cn) 通用文字识别引擎(第五个 OCR 引擎)
## 已确认的接口细节(官方文档 + 官网已核实)
- 端点:`POST https://uapis.cn/api/v1/image/ocr`,multipart/form-data
- 鉴权:`X-API-Key: <key>`(uapis.cn/console 邮箱注册即生成,免费积分 4积分/次,限速 4QPS)
- 请求字段:`image_base64`(纯 base64 或 DataURI)+ `need_location="true"`(返回坐标)+ `enable_cls="true"`(方向校正)
- 响应:`words_result[]{words, location{left,top,width,height}, score}` ——**每行带位置和置信度**,结构与百度OCR几乎一致
- 布尔参数是字符串形式;图片 ≤10MB
## 修改文件
### 1. 新增 UapisOcrClient.cs
- multipart/form-data 手工拼装(net48 无 MultipartFormDataContent)
- words_result 解析 → OcrItem(location 像素坐标直接用,score 保留供图形符号过滤用)
- 错误处理:HTTP 错误体 {code,message} 与业务 code 非 200 双查
- Key 存 baidu_ocr.json 的 uapis_api_key
### 2. OcrClient.cs 路由加 "uapis"
- 新增 _uapis 成员 + StatusChanged 转发 + LoadConfig 注入 Key + RecognizeAsync 路由
### 3. OcrSettingsForm 第四个引擎选项
- 下拉加"UApiPro 通用OCR(免费积分/带位置)";选中显示 UApiPro Key 输入行;保存 uapis_api_key
### 4. csproj 注册 → 编译 → 关闭重启 → 交付说明
## 说明
- 该引擎带 score 置信度,图形符号过滤(<0.8 短串拦截、<0.55 长文本兜底)对它自动生效
- 4QPS 限速对人工框选节奏完全够用;免费积分计费
- 五引擎格局:百度(内置Key即用)/ 智谱GLM / 千帆PaddleOCR-VL / UApiPro,外加本地GPU rapidocr 已退役