Commit graph

4 commits

Author SHA1 Message Date
nickviljoen
9eed569587 Tone down OCR from authoritative to supplementary to reduce false positives
OCR measurements were causing the LLM to over-rely on bounding box numbers
and fail correct assets on minor measurement inaccuracies. Changes:
- All prompts now say "supplementary data" not "authoritative/primary source"
- LLM instructed to prioritise visual assessment, use OCR to confirm/question
- Alignment tolerance widened from 1.5% to 3% of width
- OCR context footer softened with accuracy caveat (~5-10px margin of error)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 13:54:00 +02:00
nickviljoen
1f6782b1ef Fix OCR element grouping: use line-level instead of block-level detection
Tesseract was grouping date + logo text into one block (e.g. "8-11 luglio
amazon prime day"), inflating the date char_height and causing false
typography failures. Now groups by (block_num, line_num) so each text
line becomes a separate element, enabling correct identification of
date, logo, and legal as distinct elements.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 13:26:11 +02:00
nickviljoen
20ed52d2a2 Fix OCR false positive on landscape formats: report margins as % of shortest side
Amazon guidelines define margins as 7% of shortest side, but OCR was only
reporting % of width — giving misleadingly small numbers on wide formats
(e.g. 2.6% of 1920px width = 50px, but 6.9% of 720px shortest side).

Now includes shortest-side percentage prominently in OCR context, plus the
7% target in pixels so the LLM can compare directly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 13:00:44 +02:00
nickviljoen
9f9777240a Add OCR layout measurement module for precise spatial QC checks
Adds Tesseract-based OCR pre-processing that computes pixel-level text
positions, margins, spacing, and alignment before LLM analysis. This
enables detection of subtle layout differences that vision models miss
(e.g. 2.8% vs 6.4% headline margin, 83px vs 39px date gap).

OCR measurements injected into 10 checks across all client profiles:
- Amazon: margins, typography, headline_layout
- Static General: element_alignment, safety_area, visual_hierarchy_general,
  text_readability_general, text_edge_clearance
- L'Oreal: text_readability
- Diageo/Unilever KV: visual_hierarchy

Non-blocking: if Tesseract is unavailable, checks run with visual
estimation only. Production requires: sudo apt install tesseract-ocr

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 11:00:07 +02:00