# abhijeet1592006/distance_calculator architecture

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

- Interactive diagram: https://gitdiagram.com/abhijeet1592006/distance_calculator
- Repository: https://github.com/abhijeet1592006/distance_calculator

## Overview

##### Project Type and Purpose
- This is a **real-time computer vision tool** (open-source script) that captures video from a camera, detects yellow objects, labels them, computes inter‐object distances (in cm), and renders annotated frames to the user.

##### File Structure Analysis
- Top-level files:
- distance_calculator.py  (main pipeline script)
- README.md              (project description & instructions)
- .gitattributes         (Git config)
- There are no distinct “frontend” or “backend” directories—this is a single-process, single-module application that directly ties video I/O, CV processing, and display.

##### Key Architectural Components
a. Video Capture
- cv2.VideoCapture: fetches raw frames from a camera device.
- Convert BGR → HSV
c. Contour Detection & Filtering
- Find contours on masked image.
- Discard small contours (area threshold > 500 px).
d. Object Labelling
- Compute bounding rect & center for each valid contour.
- Assign sequential labels (A, B, C…).
e. Distance Computation
- Compute pixel-distance between consecutive object centers (Euclidean).
- Multiply by distance_threshold (0.06912) → real-world cm.
f. Rendering / Display
-

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Real-Time CV Pipeline"
        VC["Video Capture\n(cv2.VideoCapture)"]:::capture
        PP["Pre-processing & Color Filtering\n(BGR→HSV, HSV Mask)"]:::preprocess
        CD["Contour Detection & Filtering\n(findContours, area>500)"]:::detection
        OL["Object Labelling\n(boundingRect, center, labels A,B,C…)"]:::labeling
        DC["Distance Computation\n(Euclidean → cm)"]:::computation
        RD["Rendering / Display\n(boxes, centers, lines, annotations)"]:::rendering
    end

    VC --> PP
    PP --> CD
    CD --> OL
    OL --> DC
    DC --> RD

    click VC "https://github.com/abhijeet1592006/distance_calculator/blob/main/distance_calculator.py"
    click PP "https://github.com/abhijeet1592006/distance_calculator/blob/main/distance_calculator.py"
    click CD "https://github.com/abhijeet1592006/distance_calculator/blob/main/distance_calculator.py"
    click OL "https://github.com/abhijeet1592006/distance_calculator/blob/main/distance_calculator.py"
    click DC "https://github.com/abhijeet1592006/distance_calculator/blob/main/distance_calculator.py"
    click RD "https://github.com/abhijeet1592006/distance_calculator/blob/main/distance_calculator.py"

    classDef capture fill:#f9f,stroke:#333,stroke-width:2px;
    classDef preprocess fill:#bbf,stroke:#333,stroke-width:2px;
    classDef detection fill:#bfb,stroke:#333,stroke-width:2px;
    classDef labeling fill:#fbf,stroke:#333,stroke-width:2px;
    classDef computation fill:#ffb,stroke:#333,stroke-width:2px;
    classDef rendering fill:#fbb,stroke:#333,stroke-width:2px;
```
