Skip to content

Latest commit

 

History

History
91 lines (63 loc) · 1.62 KB

File metadata and controls

91 lines (63 loc) · 1.62 KB

EasyOCR Service

This is a simple Flask server that wraps EasyOCR to conform to the LiteParse OCR API specification (see ../../OCR_API_SPEC.md).

Build and Run

# install and run (in one command)
uv run server.py

Usage

The service exposes a single endpoint:

  • POST /ocr - Perform OCR on an uploaded image

Parameters

  • file - Image file (multipart/form-data)
  • language - Language code (e.g., 'en', 'fr', 'de')

Example

curl -X POST -F "file=@image.png" -F "language=en" http://localhost:8828/ocr

Response Format

{
  "results": [
    {
      "text": "recognized text",
      "bbox": [x1, y1, x2, y2],
      "confidence": 0.95
    }
  ]
}

This conforms to the LiteParse OCR API specification.

Supported Languages

EasyOCR supports 80+ languages. Common language codes:

  • en - English
  • fr - French
  • de - German
  • es - Spanish
  • zh - Chinese
  • ja - Japanese
  • ko - Korean
  • ar - Arabic

Full list: https://www.jaided.ai/easyocr/

Use with LiteParse

Once the server is running, use it with LiteParse OSS:

# Parse with EasyOCR
lit parse document.pdf --ocr-server-url http://localhost:8828/ocr

# With specific language
lit parse document.pdf --ocr-server-url http://localhost:8828/ocr --ocr-language zh

Or in code:

import { LiteParse } from 'liteparse';

const parser = new LiteParse({
  ocrServerUrl: 'http://localhost:8828/ocr',
  ocrLanguage: 'en',
});

const result = await parser.parse('document.pdf');

Testing

If you make changes to the server, make sure to adapt and run tests:

uv run pytest test_server.py