From 2546f8abbee037ce6ce180eb2fc8425cbca53d22 Mon Sep 17 00:00:00 2001 From: Daniel Bedeleanu Date: Wed, 22 Apr 2026 10:01:03 +0300 Subject: [PATCH] refine: clarify rotation analysis to account for text orientation + tilt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous prompt only measured text baseline angle from horizontal (-45° to +45°), missing that text can be vertical/sideways, requiring larger rotations (up to ±180°). New guidance: - Measure TOTAL rotation needed to make text horizontal and readable - Account for both chassis tilt AND text orientation (horizontal vs vertical) - Example: 22° tilt + 90° vertical text = 112° total rotation - Allows full -180° to +180° range instead of limiting to ±45° No changes to item identification fields, OCR rules, or crop bounds analysis. --- config/ai_prompt.md | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/config/ai_prompt.md b/config/ai_prompt.md index 5aa7a31c..44ff1437 100644 --- a/config/ai_prompt.md +++ b/config/ai_prompt.md @@ -90,29 +90,30 @@ - Include minimal padding (10-15 pixels) around item edges - Ignore background clutter, other items, hands, reflections - ### Rotation Analysis (CRITICAL - PRECISE TEXT ANGLE MEASUREMENT) + ### Rotation Analysis (CRITICAL - ROTATION TO HORIZONTAL TEXT) - **IMPORTANT: Return SMALL angles (typically -45 to +45). Large angles (60°+) indicate measurement error.** + **IMPORTANT: Return the TOTAL ROTATION ANGLE needed to make text perfectly horizontal and readable (left-to-right, top-to-bottom, standard reading position).** **Algorithm:** 1. Locate the PRIMARY text/label on the item (part number, manufacturer, specs) - 2. Imagine a perfectly horizontal line (0°) - 3. Measure how many degrees the text baseline is rotated FROM horizontal: - - Count degrees counter-clockwise = POSITIVE value to return - - Count degrees clockwise = NEGATIVE value to return - - LIMIT: Most items need -45° to +45°. If you calculate ±60° or more, re-examine your measurement. + 2. Analyze BOTH the text orientation AND tilt: + - Is the text currently horizontal or vertical/sideways? + - Is the text tilted/rotated relative to its baseline? + 3. Calculate TOTAL rotation to standard horizontal reading: + - Chassis/image tilt: e.g., item tilted 22° → needs -22° or +22° correction + - Text orientation: if vertical → add ±90° to the tilt correction + - Combine both to get final rotation angle - 4. **Return exactly this value as `rotation_degrees`** - - SMALL adjustments: 0° to ±30° (most common) - - LARGE adjustments: ±31° to ±45° (rare, carefully verify) - - EXTREME values (±60°+): Likely error — recalculate or return 0 + 4. **Return exactly this value as `rotation_degrees`** (range: -180° to +180°) + - Counter-clockwise rotation needed = POSITIVE value + - Clockwise rotation needed = NEGATIVE value - **Measurement examples** (measure the TEXT BASELINE angle only): - - Text reads horizontally → `0` - - Text tilted slightly left (counter-clockwise), ~15-25° → `+15` to `+25` (NOT higher) - - Text tilted slightly right (clockwise), ~10-20° → `-10` to `-20` (NOT lower) - - Text perfectly vertical pointing left → `90` (only if TRULY vertical) - - Text perfectly vertical pointing right → `-90` (only if TRULY vertical) + **Measurement examples** (TOTAL rotation to make text horizontal): + - Text already horizontal → `0` + - Item tilted 22° clockwise, text horizontal → `+22` (counter-clockwise to level) + - Text vertical (pointing left), ~90° rotation needed → `+90` + - Item tilted 22° clockwise AND text vertical → `+112` (22° + 90°) + - Text pointing right (180° rotated) → `-180` or `+180` (equivalent) - If uncertain or mixed angles → `0` (safe default) ### Confidence Score