# Tesseract PSM and OEM Modes Reference for Invoice and Document OCR

> Source: https://netray.co/tools/tesseract-page-segmentation-modes-reference
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Look up every Tesseract page segmentation mode (0 to 13) and OCR engine mode (0 to 3), with notes on which to use for invoices, stamps, labels and single fields.

## Category

developer

## Audience

- ERP developer
- AP automation engineer
- Quality engineer

## Tool

**Kind:** worksheet

**Mode:** reference

**Columns:**

#### Flag

**Key:** flag

**Type:** text

#### Value

**Key:** value

**Type:** text

#### Meaning

**Key:** name

**Type:** text

#### Best used for

**Key:** best_for

**Type:** text

#### Caution

**Key:** caution

**Type:** text

**Rows:**

#### Orientation and script detection (OSD) only

**Flag:** --psm

**Value:** 0

**Best for:** Detecting rotation of scanned pages before real OCR

**Caution:** Produces no text output

#### Automatic page segmentation with OSD

**Flag:** --psm

**Value:** 1

**Best for:** Mixed scan batches where pages may be rotated

**Caution:** Slower than mode 3; OSD needs the osd traineddata file

#### Automatic page segmentation, no OSD or OCR

**Flag:** --psm

**Value:** 2

**Best for:** Not used in practice

**Caution:** Documented as not implemented

#### Fully automatic page segmentation, no OSD (default)

**Flag:** --psm

**Value:** 3

**Best for:** Typical multi-block documents such as a full invoice page

**Caution:** Can merge a header table into running text

#### Assume a single column of text of variable sizes

**Flag:** --psm

**Value:** 4

**Best for:** Receipts, delivery notes and narrow tickets

**Caution:** Side by side columns get interleaved

#### Assume a single uniform block of vertically aligned text

**Flag:** --psm

**Value:** 5

**Best for:** Vertical text such as side margin stamps

**Caution:** Rarely right for normal AP documents

#### Assume a single uniform block of text

**Flag:** --psm

**Value:** 6

**Best for:** Cropped regions such as a line item table or address block

**Caution:** Gives poor results on a whole page with several layouts

#### Treat the image as a single text line

**Flag:** --psm

**Value:** 7

**Best for:** Cropped fields such as invoice number or date

**Caution:** Image must be tightly cropped to one line

#### Treat the image as a single word

**Flag:** --psm

**Value:** 8

**Best for:** Short codes such as currency or unit of measure

**Caution:** Extra whitespace in the crop hurts accuracy

#### Treat the image as a single word in a circle

**Flag:** --psm

**Value:** 9

**Best for:** Circular stamps and seals

**Caution:** Niche use

#### Treat the image as a single character

**Flag:** --psm

**Value:** 10

**Best for:** Checkbox or single digit verification

**Caution:** Not for normal fields

#### Sparse text: find as much text as possible in no particular order

**Flag:** --psm

**Value:** 11

**Best for:** Certificates, labels and forms with scattered fields

**Caution:** Reading order is not preserved, so rely on coordinates from tsv output

#### Sparse text with OSD

**Flag:** --psm

**Value:** 12

**Best for:** Scattered text on pages that may be rotated

**Caution:** Needs the osd traineddata file

#### Raw line: treat the image as a single text line, bypassing Tesseract-specific hacks

**Flag:** --psm

**Value:** 13

**Best for:** Pre-segmented line images from your own layout step

**Caution:** Use only when you control the cropping

#### Legacy engine only

**Flag:** --oem

**Value:** 0

**Best for:** Only where legacy traineddata is installed and required

**Caution:** Not available in the standard fast or best LSTM data files

#### Neural net LSTM engine only

**Flag:** --oem

**Value:** 1

**Best for:** Default choice for current traineddata on invoices and labels

**Caution:** Whitelists behave differently than with the legacy engine in older versions

#### Legacy plus LSTM engines

**Flag:** --oem

**Value:** 2

**Best for:** Rare comparison testing

**Caution:** Needs legacy data and is slower

#### Default, based on what is available

**Flag:** --oem

**Value:** 3

**Best for:** When you do not care which engine runs

**Caution:** Result can differ between machines with different language data

**Notes:** Values reflect Tesseract 4 and 5 command line options. Run tesseract --help-psm and tesseract --help-oem on your build to confirm the list, since packaged builds vary.

## Content

**Intro:** Most poor Tesseract results on invoices come from the wrong page segmentation mode, not the engine. This reference lists every --psm and --oem value with the document types where each one tends to work.

**Sections:**

#### How to use this reference

**Body:** Search by number, by document type or by phrase such as sparse or single line. Start with the full page mode (3) to see how Tesseract divides the page, then switch to a narrower mode once you have cropped a field. Keep the --oem value fixed at 1 for tests so that only one variable changes at a time. Export the table to Excel if you want to add your own column of measured accuracy per mode for your own supplier documents.

#### Choosing a mode for AP and quality documents

**Body:** A typical supplier invoice has a header block, a line table and totals, so mode 3 usually segments it acceptably, while mode 6 works well when you have already cropped the table. Certificates of conformance and packing labels hold scattered fields, where mode 11 finds more text than mode 3. For one field crops such as an invoice number, mode 7 is the standard choice.

**Bullets:**

- Full invoice page: 3, then 11 if fields are missed
- Cropped line table: 6
- Single field crop: 7 (or 8 for one token)
- Scattered label or certificate: 11
- Mixed rotation batch: 1 or 12

#### Reading results with tsv output

**Body:** Modes 11 and 12 do not preserve reading order, so do not rely on plain text. Ask for tsv output and group words by their left, top, width and height columns, then use the confidence column (conf) to flag low confidence words for human review. Tsv also lets you rebuild lines yourself, which is how most field extraction logic for ERP posting is built on top of Tesseract.

#### Common mistakes

**Body:** Using mode 7 on an uncropped page returns garbage, because the engine expects one line. Running at the wrong resolution is another frequent cause of error: Tesseract works best when text height is roughly 20 to 30 pixels, which is often reached by scanning at 300 dpi. Finally, skipping the traineddata for the right language gives poor results on accented supplier names and addresses.

**Cta:** If you want OCR output turned into validated supplier invoice or inspection records in your ERP, Netray can build a private pipeline that runs on your own servers.

**Faq:**

#### Which Tesseract PSM mode is best for invoices?

**Answer:** Mode 3 (fully automatic, the default) is the usual starting point for a whole invoice page. If fields are missed on layouts with scattered boxes, try 11. For a cropped table use 6, and for single fields use 7. Measure on a sample of your own supplier documents.

#### What is the difference between psm 6 and psm 4?

**Answer:** Mode 6 assumes one uniform block of text, such as a cropped table or paragraph. Mode 4 assumes a single column of text of variable sizes, which suits receipts and tickets with headings and body text mixed. Neither handles side by side columns on a full page well.

#### Does --oem 1 work with any traineddata?

**Answer:** OEM 1 uses the LSTM engine and works with the standard LSTM-based traineddata files, including the fast and best variants. OEM 0 and 2 need data files that still contain the legacy engine model, which many downloads do not include.

#### Why is the order of text wrong in sparse mode?

**Answer:** Sparse text modes (11 and 12) find text wherever it is, without assuming a reading order. To reconstruct lines, request tsv output and sort words by their top and left coordinates, grouping by a vertical tolerance based on text height.

## Search terms

tesseract psm modes, tesseract psm 6 vs psm 4, tesseract oem modes, tesseract page segmentation modes list, tesseract sparse text psm 11, tesseract invoice ocr settings, tesseract --psm explained

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
