# snsharma1311/object-size architecture

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

- Interactive diagram: https://gitdiagram.com/snsharma1311/object-size
- Repository: https://github.com/snsharma1311/object-size

## Overview

##### Project type and purpose
- This is an open-source Python image‐processing tool (a CLI script) that measures object dimensions in a photo based on a known reference object. It uses OpenCV and NumPy.

##### File structure
- Top-level files:
- init.py: the main script
- README.md, LICENSE
- images/: sample input images and result previews
- No sub-packages or separate “src”/“tests” directories—everything lives in init.py.

##### README for additional insights
- Dependencies: Python 3, OpenCV, NumPy.
- Algorithm steps: pre-processing → contour detection → reference calibration → measurement → drawing results.
- No external services or databases—purely local image I/O and computation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    CLI["User CLI"]:::cli

    %% File I/O
    SampleImages["Sample Images"]:::io
    ImageLoader["Image Loader"]:::io
    OutputWriter["Output Writer"]:::io

    %% Processing Pipeline
    PreProcessing["Pre-Processing<br/>(Gaussian blur + Canny)"]:::processing
    Segmentation["Segmentation<br/>(contour detection + sorting)"]:::processing
    ReferenceCal["Reference Calibration<br/>(pixels-per-cm)"]:::processing
    Measurement["Measurement Calculation"]:::processing
    Visualization["Visualization/Drawing<br/>(bounding boxes + annotation)"]:::processing

    %% External Libraries
    OpenCV["OpenCV (cv2)"]:::external
    NumPy["NumPy"]:::external

    %% Flow
    CLI -->|invoke| ImageLoader
    SampleImages -->|raw image| ImageLoader
    ImageLoader -->|raw image data| PreProcessing
    PreProcessing -->|cleaned image| Segmentation
    Segmentation -->|contours| ReferenceCal
    ReferenceCal -->|scale factor + contours| Measurement
    Measurement -->|dimensions| Visualization
    Visualization -->|annotated image| OutputWriter

    %% External deps
    OpenCV --> PreProcessing
    OpenCV --> Segmentation
    OpenCV --> Visualization
    NumPy --> PreProcessing
    NumPy --> Segmentation
    NumPy --> ReferenceCal
    NumPy --> Measurement

    %% Click Events
    click CLI "https://github.com/snsharma1311/object-size/blob/master/init.py"
    click ImageLoader "https://github.com/snsharma1311/object-size/blob/master/init.py"
    click PreProcessing "https://github.com/snsharma1311/object-size/blob/master/init.py"
    click Segmentation "https://github.com/snsharma1311/object-size/blob/master/init.py"
    click ReferenceCal "https://github.com/snsharma1311/object-size/blob/master/init.py"
    click Measurement "https://github.com/snsharma1311/object-size/blob/master/init.py"
    click Visualization "https://github.com/snsharma1311/object-size/blob/master/init.py"
    click OutputWriter "https://github.com/snsharma1311/object-size/blob/master/init.py"
    click OpenCV "https://github.com/snsharma1311/object-size/blob/master/init.py"
    click NumPy "https://github.com/snsharma1311/object-size/blob/master/init.py"
    click SampleImages "https://github.com/snsharma1311/object-size/tree/master/images/"

    %% Styles
    classDef cli fill:#f0e68c,stroke:#333,stroke-width:1px;
    classDef io fill:#e0e0e0,stroke:#333,stroke-width:1px;
    classDef processing fill:#c2f0c2,stroke:#333,stroke-width:1px;
    classDef external fill:#cce5ff,stroke:#333,stroke-width:1px;
```
