tesseract

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package tesseract reads page images with the tesseract CLI, run as a subprocess when it is installed (ADR 0043). No CGO: the binary is found on PATH or at a configured path, and a run without it falls back as the caller decides.

Tesseract and not a vision model, from a spike on 8 pages, each clean at 300 dpi and scan-like at 150 (issue #9, re-run 2026-10-20 with Google's documented OCR prompt): Tesseract 5.5.3 read them at a median CER of 2.3% and 3.3%, Gemma 4 E4B at 5.9% and 5.2% in its best shape and 32% or worse with Google's question. Gemma's errors also carry no confidence, and Tesseract's do: at 90 or more, 99.4% of its words were right.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("tesseract not found: install it, or name it with -tesseract")

ErrNotFound reports that no tesseract executable was found.

Functions

func ParseTSV

func ParseTSV(r io.Reader) ([]ocr.Word, error)

ParseTSV reads tesseract's TSV output: a header, then one row per page, block, paragraph, line and word. The rows with text are kept, which are the word rows, level 5: the others carry an empty text field, and so does a word row for a blank box.

Types

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is an ocr.Engine backed by the tesseract CLI.

func New

func New(ctx context.Context, opt Options) (*Engine, error)

New finds the executable and asks it its version, which is both the check that it runs and the name the page report gives the words it reads.

func (*Engine) Name

func (e *Engine) Name() string

Name is "tesseract <version> <lang>".

func (*Engine) Read

func (e *Engine) Read(ctx context.Context, img image.Image) ([]ocr.Word, error)

Read runs automatic segmentation and single-block mode and returns the reading with the higher confidence, single block only past singleBlockMargin.

type Options

type Options struct {
	// Exe is the tesseract executable. Empty looks for "tesseract" on PATH.
	Exe string

	// TessData is the directory holding the language models. Empty leaves it to
	// TESSDATA_PREFIX or the installation's default.
	TessData string

	// Lang is the language model, "eng" when empty.
	Lang string

	// DPI is the resolution the images are rendered at. Zero lets Tesseract estimate it, which
	// it does from the text and gets wrong on a sparse page.
	DPI float64
}

Options configure an Engine.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL