# tangsanli5201/deeppcb architecture

> Architecture diagram of the GitHub repository tangsanli5201/deeppcb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tangsanli5201/deeppcb
- Repository: https://github.com/tangsanli5201/deeppcb

## Overview

DeepPCB is a PCB-defect dataset accompanied by a Qt annotation tool and scripts for evaluating detection submissions. The main user workflow is to open paired test/template images, edit defect regions and labels, and save annotations; a separate evaluation workflow compares submitted detections with ground truth and reports AP, precision, recall, and F-score. The README documents dataset preparation and benchmark conventions; source excerpts show the annotation and evaluation call paths. The model approach is described but its implementation is not present in this repository.

Main entry points: [`tools/PCBAnnotationTool/mainwindow.cpp`](https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/mainwindow.cpp) (Annotation workflow), [`evaluation/script.py`](https://github.com/tangsanli5201/deeppcb/blob/master/evaluation/script.py) (Evaluation script), [`PCBData`](https://github.com/tangsanli5201/deeppcb/tree/master/PCBData) (Image pairs), [`tools/PCBAnnotationTool/main.cpp`](https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/main.cpp) (Annotation app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["PCB dataset"]
  node_pcbdata["Image pairs"]
  node_labels["Defect labels"]
end

subgraph group_annotation["Annotation tool"]
  node_app["Annotation app<br/>[main.cpp]"]
  node_window["Annotation workflow<br/>[mainwindow.cpp]"]
  node_draw["Test image editor<br/>[drawwidget.cpp]"]
  node_template["Template viewer<br/>[imagewidget.cpp]"]
  node_defecttypes["Defect types<br/>[datadef.h]"]
  node_typeformat["Type labels<br/>[utils.cpp]"]
end

subgraph group_evaluation["Benchmark evaluation"]
  node_evaluator["Evaluation script<br/>[script.py]"]
  node_evalhelpers["Evaluation helpers"]
  node_metrics["Benchmark metrics<br/>[script.py]"]
end

node_annotator(("Annotator"))
node_submission["Detection submission"]

node_annotator -->|"opens"| node_app
node_app -->|"creates"| node_window
node_window -->|"loads pairs"| node_pcbdata
node_window -->|"edits test"| node_draw
node_window -->|"shows template"| node_template
node_window -->|"reads and saves"| node_labels
node_window -->|"uses types"| node_defecttypes
node_window -->|"formats labels"| node_typeformat
node_annotator -->|"runs evaluation"| node_evaluator
node_submission -->|"provides detections"| node_evaluator
node_pcbdata -->|"provides ground truth"| node_evaluator
node_evaluator -->|"loads and parses"| node_evalhelpers
node_evaluator -->|"computes metrics"| node_metrics

click node_pcbdata "https://github.com/tangsanli5201/deeppcb/tree/master/PCBData"
click node_labels "https://github.com/tangsanli5201/deeppcb/tree/master/PCBData"
click node_app "https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/main.cpp"
click node_window "https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/mainwindow.cpp"
click node_draw "https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/drawwidget.cpp"
click node_template "https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/imagewidget.cpp"
click node_defecttypes "https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/datadef.h"
click node_typeformat "https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/utils.cpp"
click node_evaluator "https://github.com/tangsanli5201/deeppcb/blob/master/evaluation/script.py"
click node_evalhelpers "https://github.com/tangsanli5201/deeppcb/blob/master/evaluation/rrc_evaluation_funcs.py"
click node_metrics "https://github.com/tangsanli5201/deeppcb/blob/master/evaluation/script.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_pcbdata,node_labels toneBlue
class node_app,node_window,node_draw,node_template,node_defecttypes,node_typeformat toneAmber
class node_evaluator,node_evalhelpers,node_metrics toneMint
class node_annotator,node_submission toneIndigo
```

## Components

### PCB dataset

- [Image pairs](https://github.com/tangsanli5201/deeppcb/tree/master/PCBData): `PCBData`
- [Defect labels](https://github.com/tangsanli5201/deeppcb/tree/master/PCBData): `PCBData`

### Annotation tool

- [Annotation app](https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/main.cpp): `tools/PCBAnnotationTool/main.cpp`
- [Annotation workflow](https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/mainwindow.cpp): `tools/PCBAnnotationTool/mainwindow.cpp`
- [Test image editor](https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/drawwidget.cpp): `tools/PCBAnnotationTool/drawwidget.cpp`
- [Template viewer](https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/imagewidget.cpp): `tools/PCBAnnotationTool/imagewidget.cpp`
- [Defect types](https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/datadef.h): `tools/PCBAnnotationTool/datadef.h`
- [Type labels](https://github.com/tangsanli5201/deeppcb/blob/master/tools/PCBAnnotationTool/utils.cpp): `tools/PCBAnnotationTool/utils.cpp`

### Benchmark evaluation

- [Evaluation script](https://github.com/tangsanli5201/deeppcb/blob/master/evaluation/script.py): `evaluation/script.py`
- [Evaluation helpers](https://github.com/tangsanli5201/deeppcb/blob/master/evaluation/rrc_evaluation_funcs.py): `evaluation/rrc_evaluation_funcs.py`
- [Benchmark metrics](https://github.com/tangsanli5201/deeppcb/blob/master/evaluation/script.py): `evaluation/script.py`

### Other components

- **Annotator**
- **Detection submission**

## Connections

- Annotator → Annotation app: opens (evidence: `tools/PCBAnnotationTool/main.cpp`)
- Annotation app → Annotation workflow: creates (evidence: `tools/PCBAnnotationTool/main.cpp`)
- Annotation workflow → Image pairs: loads pairs (evidence: `tools/PCBAnnotationTool/mainwindow.cpp`)
- Annotation workflow → Test image editor: edits test (evidence: `tools/PCBAnnotationTool/mainwindow.cpp`)
- Annotation workflow → Template viewer: shows template (evidence: `tools/PCBAnnotationTool/mainwindow.cpp`)
- Annotation workflow → Defect labels: reads and saves (evidence: `tools/PCBAnnotationTool/mainwindow.cpp`)
- Annotation workflow → Defect types: uses types (evidence: `tools/PCBAnnotationTool/mainwindow.cpp`)
- Annotation workflow → Type labels: formats labels (evidence: `tools/PCBAnnotationTool/mainwindow.cpp`)
- Annotator → Evaluation script: runs evaluation (evidence: `README.md`)
- Detection submission → Evaluation script: provides detections (evidence: `README.md`)
- Image pairs → Evaluation script: provides ground truth (evidence: `README.md`)
- Evaluation script → Evaluation helpers: loads and parses (evidence: `evaluation/script.py`)
- Evaluation script → Benchmark metrics: computes metrics (evidence: `evaluation/script.py`)
