Skip to content

fix(ocr): long text lines lost most characters (#3) - #4

Merged
RGB-loop merged 1 commit into
mainfrom
fix-ocr-long-lines
Oct 17, 2026
Merged

RGB-loop merged 1 commit into
mainfrom
fix-ocr-long-lines

Conversation

@RGB-loop

Copy link
Copy Markdown
Owner

Fixes the OCR part of #3: on text-heavy screenshots, long lines came back with most characters missing.

Cause — recognition capped each text line's input width at 320 px (height 48 → aspect ratio < 7). A line of 30–40 CJK characters was squeezed to ~8 px per glyph and the model dropped most of it. PaddleOCR sizes the width from each line's aspect ratio, which is why the reporter's local PaddleOCR read the same image fully.

Fix

  • REC_MAX_WIDTH 320 → 3200 (aspect ≈ 66; a single 3×48×3200 crop is ~1.8 MB).
  • Sort crops by width before batching (as PaddleOCR does) so batches pad little; callers already re-sort lines by position.
  • OCR_PIPELINE_VERSION → v5-wide: existing libraries re-run OCR automatically after updating.

Verified

  • The issue's screenshot: output now matches the reporter's PaddleOCR output line for line (before: lines like ,清,, 低在,很到动,).
  • Demo library (20 images): 17 identical, 3 photo signs/handwriting differ by a character or two (some better, e.g. HOP DELUSION, white code). OCR-dependent eval queries (dost, OLD SACRAMENTO) still match.
  • npm test passed, typecheck clean.

…ters (#3)

Recognition capped every line's input width at 320 (aspect < 7); a 30–40 character
line got crushed to ~8px per glyph. PaddleOCR sizes width by aspect ratio — raise the
cap to 3200 and sort crops by width before batching (as Paddle does) to keep padding
small. Reproduced with the issue's screenshot: output now matches PaddleOCR line for
line. OCR_PIPELINE_VERSION → v5-wide so existing libraries re-OCR automatically.
Demo library: 17/20 images identical, 3 differ by a character or two.
@RGB-loop
RGB-loop merged commit 9b8f761 into main Oct 17, 2026
2 checks passed
@RGB-loop RGB-loop mentioned this pull request Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant