From 1e7dd064f93802660c6c4daed7fc90332d6988ea Mon Sep 17 00:00:00 2001 From: Daniel Bedeleanu Date: Wed, 22 Apr 2026 09:40:40 +0300 Subject: [PATCH] improve: clarify rotation detection in AI extraction prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Emphasize MEASURING TEXT ANGLE precisely, not item orientation - Add explicit calibration examples (22°, 90°, -45°, etc.) - Clarify positive = counter-clockwise, negative = clockwise - Help AI understand baseline measurement concept - Keep all field identification rules unchanged --- config/ai_prompt.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/config/ai_prompt.md b/config/ai_prompt.md index af936416..a54c1385 100644 --- a/config/ai_prompt.md +++ b/config/ai_prompt.md @@ -90,14 +90,26 @@ - Include minimal padding (10-15 pixels) around item edges - Ignore background clutter, other items, hands, reflections - ### Rotation Analysis - - Check if item labels/text are readable - - If text is rotated (not horizontal), calculate rotation needed - - Return `rotation_degrees`: degrees to rotate CLOCKWISE to make text readable - - Examples: - - Text rotated 90° counter-clockwise → return 90 (rotate 90° clockwise) - - Text rotated 45° clockwise → return -45 (rotate 45° counter-clockwise) - - Text already readable → return 0 + ### Rotation Analysis (CRITICAL - MEASURE TEXT ANGLE) + + **PRIORITY: Measure text orientation, not item orientation** + + 1. **Locate readable text** on the item (part numbers, manufacturer names, specifications, labels) + 2. **Measure the baseline angle of that text**: + - Baseline = the invisible line the text sits on + - 0° = text baseline is HORIZONTAL (readable left-to-right) + - Positive degrees = text rotated counter-clockwise from horizontal + - Negative degrees = text rotated clockwise from horizontal + 3. **Return clockwise rotation needed to make text horizontal**: + - If text tilted 22° counter-clockwise → return `+22` (rotate 22° clockwise to fix) + - If text tilted 15° clockwise → return `-15` (rotate 15° counter-clockwise to fix) + - If text already horizontal → return `0` + 4. **Calibration examples** (measure the text angle precisely): + - Text reads perfectly left-to-right → `rotation_degrees: 0` + - Text tilted counter-clockwise, needs ~22° clockwise to straighten → `rotation_degrees: 22` + - Text vertical, pointing left (rotated 90° counter-clockwise) → `rotation_degrees: 90` + - Text vertical, pointing right (rotated 90° clockwise) → `rotation_degrees: -90` + - Text tilted clockwise by ~45° → `rotation_degrees: -45` ### Confidence Score - Return `confidence`: 0.0-1.0 indicating reliability of crop/rotation analysis