StagesRecognise

TesseractOcr

A whole page through Tesseract's own layout analysis — the one stage that returns word-level boxes without a detector.

Import
import { TesseractOcr } from '@stabrise/scaledp/ocr'
Group
Recognise
Reads
image
Writes
document
Needs
tesseract-wasm

Tesseract does its own page segmentation, so this stage needs no detector and returns word boxes rather than line boxes. That makes it the simplest route to word-level geometry on clean Latin scans.

import { Pipeline, configure } from '@stabrise/scaledp'
import { PdfToImage } from '@stabrise/scaledp/pdf'
import { TesseractOcr } from '@stabrise/scaledp/ocr'

configure({ tesseract: { workerUrl: '/tesseract/tesseract-worker.js', dataUrl: '/tesseract/' } })

const rows = await new Pipeline([
    new PdfToImage({ resolution: 300 }),
    new TesseractOcr({ lang: ['eng'], keepFormatting: true }),
]).transform(file)
Open in builder

Document.type is 'tesseract'.

Languages

lang is an array joined with + for tesseract-wasm, so ['eng', 'deu'] loads both. Each language is roughly 15 MB of traineddata. An empty array is rejected by the constructor.

By default the data comes from the tessdata_fast repository on GitHub, which is fine for a demo and not for production — point configure({ tesseract: { dataUrl } }) at your own copy.

Where it stands against the others

Box levelWeightsWebGPU
TesseractOcrword~15 MB per languageno
PaddleTextRecognizerline~6 MByes
TesseractRecognizerline, or word with boxLevel~15 MB per languageno

No ONNX is involved, so execution providers and thread settings do not apply to it. It is a good fallback where WebGPU is absent and the document is clean, and a poor choice for dense or noisy scans.

Confidence is reported 0–1 here, not Tesseract's native 0–100, so scoreThreshold reads the same as on every other stage.

Parameters

ParameterTypeDefaultMeaning
langstring[]['eng']Tesseract language codes, e.g. eng or eng, deu. Each needs its traineddata file.
scoreThresholdnumber 0–10.5Drop words below this confidence.
keepFormattingbooleanfalseRebuild the original layout with spaces and blank lines.
lineTolerancenumber0Line-grouping tolerance in pixels; 0 derives it from character height.

On this page