DocAlignerpolygon
检测文档四角
返回四角坐标,用于文档裁剪与透视校正。
视觉模型
上传文件照片,获取四角坐标以裁切校正;上传护照照片,提取机读区的文本行。先在浏览器确认效果,再接入 API。
Beta 期间免费;使用 API 需创建账号。
使用方式
研究文章涵盖更多方法;目前可用产品为 DocAligner 与 MRZScanner。 博客
API
发送图片,在应用中使用返回的坐标或文字。
每个新任务使用独立目录。此命令创建 ID 文件,遇到已有文件会停止;两种示例每次都读取同一文件。请将 ID、图片与设置一起保留。
python3 -c 'import uuid; from pathlib import Path; f = Path("docsaid-operation-id.txt").open("x"); f.write(str(uuid.uuid4())); f.close()'请求示例
DOCSAID_OPERATION_ID=$(cat docsaid-operation-id.txt)
DOCSAID_CURL_STATUS=0
curl --fail-with-body --connect-timeout 10 --max-time 30 'https://docsaid.org/api/v1/models/docaligner/predict' \
--dump-header docsaid-response.headers --output docsaid-response.json \
--write-out 'HTTP %{http_code}\n' \
-H "Authorization: Bearer ${DOCSAID_API_KEY:?Set DOCSAID_API_KEY first}" \
-H "Idempotency-Key: ${DOCSAID_OPERATION_ID:?Create an operation ID first}" \
-F 'model_version=docaligner-1.1.1-fastvit-sa24-7f9f5a89' \
-F 'do_center_crop=false' \
-F '[email protected]' || DOCSAID_CURL_STATUS=$?
awk 'tolower($0) ~ /^(http|x-request-id:|x-error-code:|retry-after:)/' docsaid-response.headers
test "$DOCSAID_CURL_STATUS" -eq 0示例响应部分字段
{
"polygon": [
[13.2,701.6],
[560.4,579.3],
[640.9,912.9],
[80.6,1045.9]
]
}执行前先创建 API 密钥、设置 DOCSAID_API_KEY,并创建操作 ID 文件。Python 还需安装 requests。可从完整指南下载符合限制的测试图。
API 文档告诉我们你的产品、部署环境与需要的模型能力,我们会评估后通过 Email 回复。