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 回覆。