Files
SnapOtter/apps/docs/zh-TW/tools/image/ocr.md
T
SnapOtterandGitHub 4963ab3bbd feat(docs-i18n): translate all documentation into 20 languages
All 181 docs markdown files translated into 20 languages (apps/docs/<locale>/**). Companion to the i18n code PR; admin-merged because the file count exceeds GitHub's per-PR CI trigger limit. Validated by pnpm i18n:check (all surfaces, 0 stale/missing) and a clean all-locale docs build.
2026-07-11 13:52:47 +08:00

2.3 KiB
Raw Blame History

description, i18n_source_hash, i18n_provenance, i18n_output_hash
description i18n_source_hash i18n_provenance i18n_output_hash
使用 AI 驅動的光學字元辨識從圖片擷取文字。 3d85d423b82c human 3b9f7c3af638

OCR/文字擷取

使用 AI 驅動的光學字元辨識從圖片擷取文字。支援多種語言與品質層級。

API 端點

POST /api/v1/tools/image/ocr

處理方式: 同步 JSON 回應。若提供 clientJobId,也會透過 SSE 回報進度。

模型套件包: ocr5-6 GB

參數

參數 類型 必填 預設值 說明
file file - 圖片檔案(multipart
quality string "balanced" 品質層級:fastTesseract)、balancedPaddleOCR v5)、bestPaddleOCR VL
language string "auto" 語言提示:autoendefreszhjako
enhance boolean true 預先處理圖片以提高 OCR 準確度
engine string - 已淘汰。請改用 quality。將 tesseract 對應至 fast,將 paddleocr 對應至 balanced

範例請求

curl -X POST http://localhost:1349/api/v1/tools/image/ocr \
  -F "file=@document.png" \
  -F 'settings={"quality":"best","language":"en","enhance":true}'

回應(200 OK

{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "filename": "document.png",
  "text": "Extracted text content from the image...",
  "engine": "paddleocr-vl"
}

進度(SSE,選用)

若提供 clientJobId 表單欄位,則會串流傳送進度事件:

event: progress
data: {"phase":"processing","stage":"Recognizing text...","percent":50}

注意事項

  • 需要安裝 ocr 模型套件包(5-6 GB)。
  • OCR 會直接傳回擷取的文字,而非圖片下載 URL。
  • 使用備援鏈結:若較高品質的層級當機(例如 PaddleOCR segfault),會自動以下一個較低層級重試。
  • 若某層級傳回空白文字但未當機,也會退回至下一個層級。
  • 品質層級對應各引擎:fast = Tesseract、balanced = PaddleOCR v5、best = PaddleOCR VL。
  • 透過自動解碼支援 HEIC/HEIF、RAW、TGA、PSD、EXR 與 HDR 輸入格式。