Files
tfm_ainventory/config/ai_prompt.md
Daniel Bedeleanu 8091cf8802 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.
2026-04-22 10:39:23 +03:00

6.9 KiB

Technical Inventory Hardware Extraction Protocol

Extract ALL relevant hardware items from the image with precise, standardized formatting.

Filtering Rules

  • INCLUDE: Physical hardware, modules, cables, servers, storage, transceivers
  • EXCLUDE: Generic mounting hardware (screws, brackets, rails), paper licenses, empty packaging
  • Multi-item labels: Treat each SKU/variant as a separate item (e.g., "5m cable" and "7m cable" = 2 items)

Item Field Format (CRITICAL)

[]

Component Rules:

  • <size_or_length>:

    • STORAGE CAPACITY - HUMAN READABLE: Convert to largest unit (TB/MB).
      • Examples: "1600GB" → "1.6TB", "256GB" → "256GB", "512MB" → "512MB"
      • Rule: If ≥1000GB, use TB. If ≥1000MB, use GB. Otherwise use MB.
    • CABLE/WIRE LENGTH: Meters only. Examples: "5m", "10m", "50m"
    • RAM DIMM: Capacity in GB. Examples: "128GB", "32GB", "8GB"
  • <part_number>: Part number ONLY if visible. If the item has an identifiable Part Number, search web for what item this is and extract needed informations or compare with what was already identified, and correct all fields. Omit serial numbers.

  • <type>: Asset class. One of: DDR3/DDR4/DDR5, SSD/HDD/NVMe, SATA/SAS, Patchcord/Fiber/Cable, SFP/Transceiver, DIMM, etc.

  • <vendor>: Manufacturer (HP, HPE, Dell, Samsung, Cisco, Hynix, Intel, Broadcom)

  • <connector>: Physical interface (RJ45, LC-LC, MPO, U.3, SATA, SAS, ST, SC). Omit if N/A.

Item Examples (WITH HUMAN-READABLE SIZES):

  • 1.6TB NVMe HPE U.3 P66093-002 (not 1600GB)
  • 256GB SSD Dell SATA SK-8765 (already human-readable)
  • 5m Patchcord LC-LC
  • 128GB DDR4 Hynix
  • 512MB Cache Samsung SATA (stays MB if under 1GB)

Size Conversion Examples:

  • 1600GB → 1.6TB
  • 2048GB → 2TB
  • 512GB → 512GB (under 1TB threshold)
  • 256MB → 256MB
  • 1024MB → 1GB

Restrictions:

  • No comments in parenthesis
  • No measurement units in Item field (e.g., "1.6TB" not "1.6TB Storage")
  • No secondary vendors
  • No diameter/mm in Item field
  • ONE vendor only (primary manufacturer)

Other Fields

  • Type: Repeat the asset class (DDR4, SSD, NVMe, Patchcord, etc.)
  • Description: Technical summary, max 5 words. Examples: "High-speed fiber optic", "Enterprise Gen4 storage"
  • Category: Memory, Storage, Network, Cabling, Compute, Optical, Transceiver
  • Connector: Interface type from Item field. Examples: "LC-LC", "RJ45", "U.3"
  • Size: HUMAN-READABLE capacity or length. Examples: "1.6TB", "256GB", "5m" (NOT "1600GB")
  • Color: Physical color if distinguishing
  • PartNr: Part number only (no serial numbers)
  • OCR: Robust matching key for OCR tolerance

OCR Field Rules (CRITICAL)

Generate a SHORT, clean matching key:

  • Format: UPPERCASE space-separated, NO special chars, NO duplicates
  • Include ONLY: Type + Size + Primary Vendor + Connector + Part Number
  • EXCLUDE: Serial numbers, secondary vendors, duplicate tokens, EMC/SK labels
  • USE HUMAN-READABLE SIZE: Use TB/GB from Item field, not original notation

OCR Format: TYPE SIZE VENDOR CONNECTOR PARTNUMBER

OCR Examples (WITH HUMAN-READABLE SIZES):

  • Item: 1.6TB NVMe HPE U.3 P66093-002 → OCR: NVME 1.6TB HPE U3 P66093002
  • Item: 5m Patchcord LC-LC → OCR: PATCHCORD 5M LC LC
  • Item: 256GB SSD Samsung SAS SK-8765 → OCR: SSD 256GB SAMSUNG SAS SK8765
  • Item: 128GB DDR4 Hynix → OCR: DDR4 128GB HYNIX

OCR Constraints:

  • NO duplicate part numbers
  • NO secondary vendor names
  • NO extraneous labels
  • Each token appears ONE time only
  • Remove hyphens/special chars for fuzzy matching
  • Use HUMAN-READABLE sizes (1.6TB not 1600GB)

Image Processing Guidance (NEW)

Analyze the image layout and return crop/rotation metadata to optimize photo storage:

Crop Bounds Analysis

  • Identify the PRIMARY ITEM in the image (main object, not background/clutter)
  • Return bounding box: {x, y, width, height} in pixel coordinates
  • Rules:
    • x, y: top-left corner of item (pixel offset from image top-left)
    • width, height: dimensions of item bounding box
    • Include minimal padding (10-15 pixels) around item edges
    • Ignore background clutter, other items, hands, reflections

Rotation Analysis (CRITICAL - SMALL TILT ANGLE MEASUREMENT)

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. Measure ONLY the tilt angle: How many degrees is the text rotated from horizontal?
    • Text reads horizontally left-to-right →
    • 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)

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
  • 0.9+ = High confidence (clear item, readable text)
  • 0.7-0.89 = Medium confidence (some ambiguity or text partially obscured)
  • <0.7 = Low confidence (cluttered image, unclear item boundaries)

Output Format (Extended)

{
  "items": [
    {
      "Item": "[size] type vendor connector partnumber",
      "Type": "type",
      "Description": "technical details (max 5 words)",
      "Category": "category",
      "Connector": "connector_type",
      "Size": "human_readable_size",
      "Color": "color",
      "PartNr": "part_number",
      "OCR": "TYPE SIZE VENDOR CONNECTOR PARTNUMBER",
      "image_processing": {
        "crop_bounds": {
          "x": 50,
          "y": 100,
          "width": 300,
          "height": 200
        },
        "rotation_degrees": 15,
        "confidence": 0.92
      }
    }
  ]
}

Return ONLY JSON. No markdown. No text.