# 02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv architecture

> Architecture diagram of the GitHub repository 02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv
- Repository: https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv

## Overview

This is a parking-space occupancy monitor: users mark spaces on an image, then the video program classifies each marked region as free or occupied and displays a live count. The sampled runtime uses image thresholding and pixel counts—not YOLO vehicle detection—despite the README’s broader description. The graph reflects the sampled code; the README also describes image-mode detection and YOLO capabilities whose implementation is not evident in the supplied source.

Main entry points: [`main.py`](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/main.py) (Video Loop), [`1.py`](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/1.py) (Mark Spaces), [`CarParkPos`](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/CarParkPos) (Space Positions), [`faultcode.py`](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/faultcode.py) (Alternate Metrics)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Space Setup"]
  node_setup_ui["Mark Spaces<br/>[1.py]"]
end

subgraph group_monitor["Video Monitoring"]
  node_monitor_loop["Video Loop<br/>[main.py]"]
  node_preprocess["Frame Preprocessing<br/>[main.py]"]
  node_occupancy["Space Classification<br/>[main.py]"]
  node_overlay["Results Overlay<br/>[main.py]"]
  node_alternate["Alternate Metrics<br/>[faultcode.py]"]
end

subgraph group_assets["Parking Data"]
  node_positions["Space Positions"]
  node_sample_image["Setup Image"]
  node_video["Parking Video<br/>[carPark.mp4]"]
end

node_user(("User"))

node_user -->|"marks spaces"| node_setup_ui
node_sample_image -->|"loads image"| node_setup_ui
node_setup_ui -->|"saves coordinates"| node_positions
node_user -->|"quits playback"| node_monitor_loop
node_video -->|"supplies frames"| node_monitor_loop
node_positions -->|"loads coordinates"| node_monitor_loop
node_monitor_loop -->|"passes frames"| node_preprocess
node_monitor_loop -->|"checks spaces"| node_occupancy
node_occupancy -->|"sends status"| node_overlay
node_overlay -->|"displays results"| node_user
node_alternate -->|"reads video"| node_video
node_alternate -->|"loads coordinates"| node_positions

click node_setup_ui "https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/1.py"
click node_positions "https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/CarParkPos"
click node_video "https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/carPark.mp4"
click node_monitor_loop "https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/main.py"
click node_preprocess "https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/main.py"
click node_occupancy "https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/main.py"
click node_overlay "https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/main.py"
click node_alternate "https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/faultcode.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_setup_ui,node_user toneBlue
class node_monitor_loop,node_preprocess,node_occupancy,node_overlay,node_alternate toneAmber
class node_positions,node_sample_image,node_video toneMint
```

## Components

### Space Setup

- [Mark Spaces](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/1.py): `1.py`

### Video Monitoring

- [Video Loop](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/main.py): `main.py`
- [Frame Preprocessing](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/main.py): `main.py`
- [Space Classification](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/main.py): `main.py`
- [Results Overlay](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/main.py): `main.py`
- [Alternate Metrics](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/faultcode.py): `faultcode.py`

### Parking Data

- [Space Positions](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/CarParkPos): `CarParkPos`
- **Setup Image**
- [Parking Video](https://github.com/02-debug/ai-powered-car-parking-space-detection-using-yolov8-opencv/blob/main/carPark.mp4): `carPark.mp4`

### Other components

- **User**

## Connections

- User → Mark Spaces: marks spaces
- Setup Image → Mark Spaces: loads image
- Mark Spaces → Space Positions: saves coordinates
- User → Video Loop: quits playback
- Parking Video → Video Loop: supplies frames
- Space Positions → Video Loop: loads coordinates
- Video Loop → Frame Preprocessing: passes frames
- Video Loop → Space Classification: checks spaces
- Space Classification → Results Overlay: sends status
- Results Overlay → User: displays results
- Alternate Metrics → Parking Video: reads video
- Alternate Metrics → Space Positions: loads coordinates
