# sivaprakash2k3/container-door-detection architecture

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

- Interactive diagram: https://gitdiagram.com/sivaprakash2k3/container-door-detection
- Repository: https://github.com/sivaprakash2k3/container-door-detection

## Overview

This is a single-script video application that tracks container detections and classifies each tracked crop as Open or Closed. The main workflow reads video frames, runs YOLO tracking, preprocesses each crop, combines two intensity-based decisions using a per-object reference image, and overlays results for display. The graph reflects the inspected script and README; input and model paths are hard-coded, and no separate persistence or service layer is shown.

Main entry points: [`door_state_detection.py`](https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py) (Container Crop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Video Detection Runtime"]
  node_video["Video Input"]
  node_tracking["YOLO Tracking"]
  node_crop["Container Crop"]
  node_reference[("Per-ID Reference")]
end

subgraph group_analysis["Image Analysis"]
  node_preprocess["Contour Preprocessing"]
  node_intensity["Side Intensity"]
  node_reference_diff["Reference Difference"]
  node_decision["State Decision"]
end

subgraph group_presentation["Result Display"]
  node_overlay["Overlay Rendering"]
  node_display["Video Display"]
end

node_operator(("Operator"))

node_operator -->|"provides footage"| node_video
node_video -->|"reads frames"| node_tracking
node_tracking -->|"yields boxes"| node_crop
node_crop -->|"extracts contours"| node_preprocess
node_crop -->|"analyzes gray crop"| node_intensity
node_crop -->|"initializes per ID"| node_reference
node_reference -->|"supplies baseline"| node_reference_diff
node_crop -->|"compares frame"| node_reference_diff
node_intensity -->|"supplies state"| node_decision
node_reference_diff -->|"supplies state"| node_decision
node_decision -->|"sets label"| node_overlay
node_preprocess -->|"supplies contours"| node_overlay
node_overlay -->|"draws results"| node_display

click node_video "https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py"
click node_tracking "https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py"
click node_crop "https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py"
click node_preprocess "https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py"
click node_reference "https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py"
click node_intensity "https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py"
click node_reference_diff "https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py"
click node_decision "https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py"
click node_overlay "https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py"
click node_display "https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.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_video,node_tracking,node_crop,node_reference toneBlue
class node_preprocess,node_intensity,node_reference_diff,node_decision toneAmber
class node_overlay,node_display toneMint
class node_operator toneIndigo
```

## Components

### Video Detection Runtime

- [Video Input](https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py): `door_state_detection.py`
- [YOLO Tracking](https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py): `door_state_detection.py`
- [Container Crop](https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py): `door_state_detection.py`
- [Per-ID Reference](https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py): `door_state_detection.py`

### Image Analysis

- [Contour Preprocessing](https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py): `door_state_detection.py`
- [Side Intensity](https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py): `door_state_detection.py`
- [Reference Difference](https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py): `door_state_detection.py`
- [State Decision](https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py): `door_state_detection.py`

### Result Display

- [Overlay Rendering](https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py): `door_state_detection.py`
- [Video Display](https://github.com/sivaprakash2k3/container-door-detection/blob/main/door_state_detection.py): `door_state_detection.py`

### Other components

- **Operator**

## Connections

- Operator → Video Input: provides footage (evidence: `README.md`)
- Video Input → YOLO Tracking: reads frames (evidence: `door_state_detection.py`)
- YOLO Tracking → Container Crop: yields boxes (evidence: `door_state_detection.py`)
- Container Crop → Contour Preprocessing: extracts contours (evidence: `door_state_detection.py`)
- Container Crop → Side Intensity: analyzes gray crop (evidence: `door_state_detection.py`)
- Container Crop → Per-ID Reference: initializes per ID (evidence: `door_state_detection.py`)
- Per-ID Reference → Reference Difference: supplies baseline (evidence: `door_state_detection.py`)
- Container Crop → Reference Difference: compares frame (evidence: `door_state_detection.py`)
- Side Intensity → State Decision: supplies state (evidence: `door_state_detection.py`)
- Reference Difference → State Decision: supplies state (evidence: `door_state_detection.py`)
- State Decision → Overlay Rendering: sets label (evidence: `door_state_detection.py`)
- Contour Preprocessing → Overlay Rendering: supplies contours (evidence: `door_state_detection.py`)
- Overlay Rendering → Video Display: draws results (evidence: `door_state_detection.py`)
