# revelrush/automatic-water-meter-reader architecture

> Architecture diagram of the GitHub repository revelrush/automatic-water-meter-reader, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/revelrush/automatic-water-meter-reader
- Repository: https://github.com/revelrush/automatic-water-meter-reader

## Overview

Automatic-Water-Meter-Reader is a command-line image-to-reading application. A user supplies a meter image and the meter’s whole-digit and total-digit counts; `main.py` coordinates counter localization, digit recognition, numeric formatting, and saving a processed-image visualization. The README describes segmentation for counter detection and Faster R-CNN for recognition, with additional preprocessing and final postprocessing. The supplied source excerpt shows the main coordinator but not the counter modules’ internals, so their internal processing and detailed detector wiring are represented conservatively.

Main entry points: [`main.py`](https://github.com/revelrush/automatic-water-meter-reader/blob/main/main.py) (Pipeline coordinator), [`CounterDetection.py`](https://github.com/revelrush/automatic-water-meter-reader/blob/main/CounterDetection.py) (Counter preprocessing), [`CounterRecognition.py`](https://github.com/revelrush/automatic-water-meter-reader/blob/main/CounterRecognition.py) (Digit preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Image localization"]
  node_main["Pipeline coordinator<br/>[main.py]"]
  node_counter_prep["Counter preprocessing"]
  node_segmentation["Counter segmentation<br/>[main.py]"]
end

subgraph group_recognition["Digit recognition"]
  node_counter_region["Counter region"]
  node_digit_prep["Digit preprocessing"]
  node_detector["Faster R-CNN detector<br/>[main.py]"]
  node_label_map["Digit labels"]
end

subgraph group_results["Reading output"]
  node_digit_reading["Recognized digits"]
  node_format_reading["Decimal formatting<br/>[main.py]"]
  node_visualization["Processed image"]
  node_save_output["Save visualization<br/>[main.py]"]
end

node_user(("CLI user"))
node_meter_image["Meter image"]
node_reading["Meter reading"]
node_saved_image["Saved image file"]

node_user -->|"provides arguments"| node_main
node_user -->|"selects"| node_meter_image
node_meter_image -->|"image path"| node_main
node_main -->|"calls detection"| node_counter_prep
node_counter_prep -->|"processes image"| node_segmentation
node_segmentation -->|"localizes counter"| node_counter_region
node_counter_region -->|"returns region"| node_main
node_main -->|"calls recognition"| node_digit_prep
node_digit_prep -->|"detects digits"| node_detector
node_main -->|"loads labels"| node_label_map
node_label_map -->|"class mapping"| node_detector
node_detector -->|"predicts digits"| node_digit_reading
node_digit_reading -->|"returns prediction"| node_main
node_main -->|"formats digits"| node_format_reading
node_format_reading -->|"produces value"| node_reading
node_main -->|"receives image"| node_visualization
node_visualization -->|"provides image"| node_save_output
node_save_output -->|"writes file"| node_saved_image

click node_main "https://github.com/revelrush/automatic-water-meter-reader/blob/main/main.py"
click node_counter_prep "https://github.com/revelrush/automatic-water-meter-reader/blob/main/CounterDetection.py"
click node_segmentation "https://github.com/revelrush/automatic-water-meter-reader/blob/main/main.py"
click node_digit_prep "https://github.com/revelrush/automatic-water-meter-reader/blob/main/CounterRecognition.py"
click node_detector "https://github.com/revelrush/automatic-water-meter-reader/blob/main/main.py"
click node_format_reading "https://github.com/revelrush/automatic-water-meter-reader/blob/main/main.py"
click node_visualization "https://github.com/revelrush/automatic-water-meter-reader/blob/main/CounterRecognition.py"
click node_save_output "https://github.com/revelrush/automatic-water-meter-reader/blob/main/main.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_counter_prep,node_segmentation,node_user toneBlue
class node_counter_region,node_digit_prep,node_detector,node_label_map toneAmber
class node_digit_reading,node_format_reading,node_visualization,node_save_output toneMint
class node_meter_image,node_reading,node_saved_image toneIndigo
```

## Components

### Image localization

- [Pipeline coordinator](https://github.com/revelrush/automatic-water-meter-reader/blob/main/main.py): `main.py`
- [Counter preprocessing](https://github.com/revelrush/automatic-water-meter-reader/blob/main/CounterDetection.py): `CounterDetection.py`
- [Counter segmentation](https://github.com/revelrush/automatic-water-meter-reader/blob/main/main.py): `main.py`

### Digit recognition

- **Counter region**
- [Digit preprocessing](https://github.com/revelrush/automatic-water-meter-reader/blob/main/CounterRecognition.py): `CounterRecognition.py`
- [Faster R-CNN detector](https://github.com/revelrush/automatic-water-meter-reader/blob/main/main.py): `main.py`
- **Digit labels**

### Reading output

- **Recognized digits**
- [Decimal formatting](https://github.com/revelrush/automatic-water-meter-reader/blob/main/main.py): `main.py`
- [Processed image](https://github.com/revelrush/automatic-water-meter-reader/blob/main/CounterRecognition.py): `CounterRecognition.py`
- [Save visualization](https://github.com/revelrush/automatic-water-meter-reader/blob/main/main.py): `main.py`

### Other components

- **CLI user**
- **Meter image**
- **Meter reading**
- **Saved image file**

## Connections

- CLI user → Pipeline coordinator: provides arguments
- CLI user → Meter image: selects
- Meter image → Pipeline coordinator: image path
- Pipeline coordinator → Counter preprocessing: calls detection
- Counter preprocessing → Counter segmentation: processes image
- Counter segmentation → Counter region: localizes counter
- Counter region → Pipeline coordinator: returns region
- Pipeline coordinator → Digit preprocessing: calls recognition
- Digit preprocessing → Faster R-CNN detector: detects digits
- Pipeline coordinator → Digit labels: loads labels
- Digit labels → Faster R-CNN detector: class mapping
- Faster R-CNN detector → Recognized digits: predicts digits
- Recognized digits → Pipeline coordinator: returns prediction
- Pipeline coordinator → Decimal formatting: formats digits
- Decimal formatting → Meter reading: produces value
- Pipeline coordinator → Processed image: receives image
- Processed image → Save visualization: provides image
- Save visualization → Saved image file: writes file
