#1957·xberg

bug(ocr): widely spaced invoice rows truncate tables and lose quantity

Author: GoldziherCreated Sep 29, 2026Updated Sep 29, 2026
Labelsbugneeds-triage

Reproduction

With xberg 1.3.0, OCR/table detection enabled, English, no layout model, and default image OCR segmentation, a synthetic invoice PNG (1800 × 2300) loses its final line-item quantity and truncates the structured table. This reproduces on Linux arm64 in CI and locally on macOS arm64 (Tesseract 5.5.3).

The exact input SHA-256 is e2b891280438e61e3c5474f39e122620ac91b191fa089ec84b4ab45045691f02. The image is not attached because its repository is private; no customer document or credentials are included here.

Expected: one four-column line-item table with headings DESCRIPTION, QTY, UNIT PRICE, LINE TOTAL; three line items have quantities 10, 200, and 5.

Actual: the surviving line-item table contains only its header and first item. Its headings are DESCRIPTION, QTY UNIT, PRICE LINE, TOTAL. The final item remains in text output with its unit price and line total, but quantity 5 is absent.

Fresh, isolated XBERG_CACHE_DIR runs with both extraction and nested Tesseract caches disabled reproduce the failure. Explicit English nested Tesseract configuration is set. Default/implicit segmentation and explicit PSM 11 produce the same failure; this is not a stale-cache result.

Observed table-region trace

Before post-processing, the line-item header and first item form one region (raw_rows=2, raw_cols=6). The second item becomes a separate region (raw_rows=1, raw_cols=4). The last item becomes another region with four recognized words and is skipped because it falls below MIN_TABLE_CANDIDATE_WORDS=6.

The existing bounded blank-quantity retry does not see a complete QTY column: the rows have already been separated and the surviving header is missegmented. Lowering the minimum word count alone would not restore the missing quantity or correct headings.

Likely investigation area: vertical-gap region clustering and continuation-row/header geometry before reconstruction. This is a diagnosis hypothesis, not a validated fix. Add controls for widely spaced continuation rows, separate same-column tables, intervening prose/new headers, intentional blank quantities, and multiple missing cells before changing grouping.

Related work: #1950 and #1954 address split amount columns, but no verified fix for this specific row-splitting/missing-quantity case has been established. A pass/fail bracket against 1.2.7 has not been performed, so attribution to a particular introducing commit is not claimed.