refine: clarify rotation analysis for EXIF-stripped raw images

Key changes:
- Explicitly state image has EXIF orientation stripped (raw/native state)
- Return ONLY the tilt angle, not orientation shifts
- Expect small angles (-45° to +45°), not large ones
- Add safety check: if angle > 45°, likely measurement error
- Simplify examples to show tilt-only measurement

This ensures Gemini returns consistent, sane rotation values regardless
of the item or how the photo was taken, without needing local offsets.
This commit is contained in:
2026-04-22 10:39:23 +03:00
parent 500d090dfc
commit 8091cf8802

View File

@@ -90,31 +90,30 @@
- Include minimal padding (10-15 pixels) around item edges
- Ignore background clutter, other items, hands, reflections
### Rotation Analysis (CRITICAL - ROTATION TO HORIZONTAL TEXT)
### Rotation Analysis (CRITICAL - SMALL TILT ANGLE MEASUREMENT)
**IMPORTANT: Return the TOTAL ROTATION ANGLE needed to make text perfectly horizontal and readable (left-to-right, top-to-bottom, standard reading position).**
**IMPORTANT: The image has EXIF orientation metadata stripped. Analyze it in its RAW/NATIVE state.**
**Return the SMALL tilt angle needed to make the text perfectly horizontal and readable.**
**Algorithm:**
1. Locate the PRIMARY text/label on the item (part number, manufacturer, specs)
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
2. **Measure ONLY the tilt angle**: How many degrees is the text rotated from horizontal?
- Text reads horizontally left-to-right → `0°`
- Text tilted slightly clockwise (right side up) → **negative angle** (e.g., `-15°`)
- Text tilted slightly counter-clockwise (left side up) → **positive angle** (e.g., `+20°`)
3. **IGNORE text orientation** (vertical/sideways): The image is in raw/native state, so text orientation is simply directional tilt, not a 90° shift
4. **Return this tilt angle as `rotation_degrees`** (expected range: **-45° to +45°**)
- Clockwise tilt = NEGATIVE value (e.g., `-22°` to level a clockwise tilt)
- Counter-clockwise tilt = POSITIVE value (e.g., `+18°` to level a counter-clockwise tilt)
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** (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)
**Measurement examples** (RAW image, EXIF-stripped, measuring ONLY tilt):
- Text reads perfectly horizontal → `0`
- Item tilted 22° clockwise (text tilts down-right) → `-22`
- Item tilted 15° counter-clockwise (text tilts up-left) → `+15`
- Item slightly rotated 5° → `-5` or `+5` depending on direction
- **SAFETY CHECK**: If your calculated angle is > ±45°, re-examine. Most hardware is only slightly tilted in photos (±30° max)
- If uncertain`0` (safe default; OpenCV fallback will handle it)
### Confidence Score
- Return `confidence`: 0.0-1.0 indicating reliability of crop/rotation analysis