mirror of
https://gitverse.ru/kpa39l/project-doc-processing.git
synced 2026-09-29 09:15:04 +00:00
2.4 KiB
2.4 KiB
Vision-reading CAD screenshots — crop & zoom technique
When the source is a PNG screenshot of a drawing sheet (rack/ТШ schematic, port→socket table) instead of a PDF, the vision model reads it directly — but dense sheets need the crop-zoom technique. This reference captures the working pattern from the vinogorod СКС screenshot sessions.
Workflow
- Probe the sheet size first (
PIL.Image.open().size). Large sheets (~2300px) read well whole; small ones (~500px) need crops. - Cut the sheet into bands (top/mid/bottom strips, left/right halves, quarters) with
img.crop(), upscale ×2-4 withImage.LANCZOS, save to /tmp. - Send each crop with a narrow, fact-only question: "перечисли все подписи по одной на строку, ничего не пропускай". Explicit formatted-single-line output beats "опиши лист".
- Timeout retry pattern: cloud vision (polza deepseek-vision) times out on dense crops — retry the SAME region as a smaller/narrower crop, or split the question. A timeout is not a dead end; the region is readable in pieces.
- Cross-check across crops of the same sheet (top = device labels, bottom = legend/tables); merge answers. Vision text is imperfect — treat "(v) vs (V)", "Swd vs SWd" as the same until proven otherwise.
- On engineer sheet sets, the legend/«Условные графические обозначения» sits at the BOTTOM of each rack sheet — crop the bottom strip for socket-code decoding. Legends can differ BETWEEN sheets of one set — verify per sheet, never copy from a previous one.
Proven example (2026-09-05)
Sheet /mnt/vinogorod/ИТ/trash/2026-09-05_08-44-17.png (2299×1789): bottom strip crop (55-100% height, ×1.6 LANCZOS) exposed the legend tables «Условные графические обозначения», «Маркировка патч-панелей», «Маркировка оборудования в шкафу». Full decode in sks-rack-legend.md.
Model quirks
- polza deepseek-vision (~0.1₽/request): fine on large sheets; times out on dense crops → narrow the crop, not the timeout.
- Small sheets (~500px wide) read worse than large ones; always upscale ×3+ before sending.
- Split one big "read everything" question into several per-region questions — the model returns cleaner single-line lists.
Cross-links
- Legend decode:
sks-rack-legend.md - Spec/table parsing (PDFs):
spec-parser-pattern.md