DEV Community

Cover image for Apryse OCR vs Tesseract vs Cloud OCR API: Tested in Python
AI Engine
AI Engine

Posted on Originally published at ai-engine.net

Apryse OCR vs Tesseract vs Cloud OCR API: Tested in Python

Apryse OCR vs Tesseract is a choice between a commercial on-premise SDK and the best-known open-source engine. There is a third option: a cloud OCR API you call over HTTP. We installed all three in Python, ran them on the same four real documents, and counted how many key facts each one read correctly.

Want to run the test on your own documents? Get a key for the OCR Wizard API.


The short answer

  • Tesseract: free, runs anywhere, good on clean prints. On worn receipts and old scans it needs preprocessing and tuning.
  • Apryse OCR: an add-on to the Apryse Server SDK. Runs on your servers, makes searchable PDFs, fits teams already using Apryse. Pricing is by quote.
  • Cloud OCR API: no install. In our test, the OCR Wizard API read every key fact on all four documents.

The test documents

  1. A 1994 Tesco receipt on thermal paper, faded and creased.
  2. A 2020 Polish supermarket receipt, photographed with a phone.
  3. Two typewritten receipts from 1913, scanned by the U.S. National Archives.

We listed the facts a business would need (prices, totals, dates, names, amounts): 33 facts in total. A point counts only when the fact appears exactly as printed.


Results: key facts read correctly

Document Tesseract 5.3 Apryse 12.2 (default) Apryse 12.2 (accurate) OCR Wizard API
Tesco receipt, 1994 (11) 1 0 0 11
Polish receipt, 2020 (8) 6 5 4 8
Rental receipt, 1913 (8) 2 1 5 8
Watchman receipt, 1913 (6) 4 2 4 6
Total (33) 13 8 13 33

Tesseract ran with page segmentation mode 6 (the default mode 3 scored 9). Apryse ran with its two documented profiles, default and accurate; the accurate one helped a lot on the 1913 scans.

The same three lines of a 1913 receipt as read by Tesseract, Apryse and the OCR Wizard API

On this scan, Tesseract turned $25.00 into $2b.00 and $12.50 into $12,600. Apryse dropped letters from the written amount and returned $350. 00. with a space, which breaks a simple amount parser. The API returned the lines as printed.

To be fair to both local engines: on a clean, sharp image of printed text, Apryse and Tesseract both read every word, and Apryse says its module is optimized for about 300 DPI input. The gap shows up on faded, low-contrast and old documents.


Speed per page

  • Tesseract 5.3: 0.3 to 1.2 s (laptop CPU)
  • Apryse, default profile: 1.7 to 4.5 s
  • Apryse, accurate profile: 6 to 15 s
  • OCR Wizard API: 0.6 to 0.8 s, network included

The code for each engine

Tesseract

Install the engine and language data, then pip install pytesseract:

import pytesseract

text = pytesseract.image_to_string("receipt.jpg", lang="eng", config="--psm 6")
print(text)
Enter fullscreen mode Exit fullscreen mode

Apryse

pip install --extra-index-url=https://pypi.apryse.com apryse-sdk apryse-ocr
Enter fullscreen mode Exit fullscreen mode
import json
import os

import apryse_ocr
from apryse_sdk import PDFDoc, PDFNet, OCRModule, OCROptions

PDFNet.Initialize(os.environ["APRYSE_KEY"])
PDFNet.AddResourceSearchPath(os.path.join(os.path.dirname(apryse_ocr.__file__), "lib"))

doc = PDFDoc()
options = OCROptions()
options.AddLang("en")
OCRModule.ImageToPDF(doc, "receipt.jpg", options)
doc.Save("receipt_searchable.pdf", 0)

data = json.loads(OCRModule.GetOCRJsonFromPDF(doc, None))
for page in data["Page"]:
    for para in page["Para"]:
        for line in para["Line"]:
            print(" ".join(word["text"] for word in line["Word"]))
Enter fullscreen mode Exit fullscreen mode

Two details cost us time: the SDK only finds the OCR module after AddResourceSearchPath points to the module's lib folder, and the module expects two-letter language codes (en, pl); pol made the call fail.

OCR Wizard API

import os

import requests

with open("receipt.jpg", "rb") as f:
    response = requests.post(
        "https://ocr-wizard.p.rapidapi.com/ocr",
        headers={
            "x-rapidapi-host": "ocr-wizard.p.rapidapi.com",
            "x-rapidapi-key": os.environ["RAPIDAPI_KEY"],
        },
        files={"image": f},
        timeout=60,
    )
response.raise_for_status()
result = response.json()["body"]
print(result["detectedLanguage"])
print(result["fullText"])
Enter fullscreen mode Exit fullscreen mode

The response also lists every word with its bounding box, useful to pair receipt items with their prices.


Setup and licensing

Tesseract Apryse OCR OCR Wizard API
License Apache 2.0, free Commercial add-on, quote-based Pay per request, free tier
Where it runs Your machines Your servers Cloud, over HTTPS
Install System package + language files SDK + OCR module + license key None
Output Text, hOCR, TSV, PDF Searchable PDF, JSON or XML JSON with word boxes
Handwriting and fields Not built in Separate add-ons Handwriting supported

Which one should you pick?

  • Tesseract for clean prints, offline tools and hobby projects, when you have time to tune.
  • Apryse when documents must stay on your servers and you already use the Apryse SDK for PDFs. Test the accurate profile on your own scans.
  • A cloud OCR API when your inputs are photos, receipts or old scans, and you want results in a few lines of code.

Full write-up with the test details: Apryse OCR vs Tesseract vs Cloud OCR API on ai-engine.net.


Sources

Try it on your own scans: grab a key from the OCR Wizard API page.

Top comments (0)