How huaweidomain77/watermark-extractor works
Watermark Extractor is a Gradio application for reading red watermark fields from survey photos and checking extracted coordinates against a master site file. Users upload images, run extraction, review results, and can optionally upload a master file for distance validation. The extraction orchestrator locates and isolates watermark text, tries local OCR with rotations and validation, and has a documented OpenAI fallback. The excerpts show core image-processing and OCR dependencies; some application wiring is only visible in the SOURCE INDEX, and the master-file relationship is documented rather than traced through the UI code.
Main entry points: extractor.py Extraction orchestrator · openai_client.py Vision fallback · text_regions.py Text region detection · app.py Gradio app
Components 17
User interface
- Gradio app
app.py
Extraction workflow
- Extraction orchestrator
core/extractor.py - Site distance check
core/distance.py
Image analysis
- Watermark locator
core/corners.py - Watermark isolator
core/watermark.py - Orientation detection
core/rotations.py - Red mask
core/red_mask.py - Text region detection
core/text_regions.py - MSER preprocessing
core/preprocess.py
OCR and validation
- Local OCR
core/tesseract_client.py - Vision fallback
core/openai_client.py - OCR quality gate
core/quality_gate.py - Extraction validation
core/validation.py - Shared helpers
utils/helpers.py
Other components
- Survey user
- OpenAI service
- Master site file
Connections 22
- Survey user → Gradio app: uploads images
README.md - Gradio app → Extraction orchestrator: runs extraction
app.py - Gradio app → Site distance check: checks distance
app.py - Extraction orchestrator → Watermark locator: locates watermark
core/extractor.py - Extraction orchestrator → Watermark isolator: isolates text
core/extractor.py - Extraction orchestrator → Orientation detection: chooses rotations
core/extractor.py - Extraction orchestrator → Local OCR: runs OCR
core/extractor.py - Extraction orchestrator → Vision fallback: fallback extraction
core/extractor.py - Extraction orchestrator → Extraction validation: validates fields
core/extractor.py - Watermark locator → Red mask: scores red pixels
core/corners.py - Watermark locator → Text region detection: filters text
core/corners.py - Watermark isolator → Red mask: masks red pixels
core/watermark.py - Watermark isolator → Text region detection: selects text regions
core/watermark.py - Orientation detection → Red mask: masks raw image
core/rotations.py - Orientation detection → Text region detection: filters raw image
core/rotations.py - Text region detection → MSER preprocessing: prepares for MSER
core/text_regions.py - Local OCR → Shared helpers: normalizes extracted fields
core/tesseract_client.py - Vision fallback → Shared helpers: normalizes extracted fields
core/openai_client.py - Vision fallback → OCR quality gate: gates response
core/openai_client.py - Vision fallback → OpenAI service: requests vision extraction
core/openai_client.py - Site distance check → Master site file: matches site IDs
README.md - Survey user → Master site file: uploads site file
README.md