# baarrii/eggwatch architecture

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

- Interactive diagram: https://gitdiagram.com/baarrii/eggwatch
- Repository: https://github.com/baarrii/eggwatch

## Overview

##### Project Type and Purpose
- EggWatch is a standalone computer vision tool geared toward real-time egg detection.
- It leverages image processing techniques (via OpenCV) and includes supporting modules for calibration, image capturing, tracking, counting, and communication.
- The main executable (EggWatch.py) acts as the central component that integrates these modules.

##### Analyzing the File Structure
- Top-level Python scripts:
- EggWatch.py: Likely the main application entry point.
- calibrator.py: Responsible for calibration routines and possibly adjusting camera settings via a configuration process.
- camera.py: Handles interfacing with the camera hardware or video stream.
- tracker.py: Implements egg detection or tracking mechanisms within image frames.
- counter.py: Manages the counting logic for detected eggs.
- sender.py and ethernetSender.py: Deal with forwarding results or sending notifications over different channels (likely distinguishing between local vs. Ethernet-based transmissions).
- config.ini: A configuration file holding settings that tweak the behavior of image capturing, calibration, network or processing parameters.

##### Key Architectural Components and Relationships
a. Main Application Controller (EggWatch.py)
- Acts as the orchestrator that initializes components.
- Reads configuration from config.ini and dispatches tasks.
b. Image Acquisition Module (camera.py)
- Captures images or video streams and feeds them into the processing pipeline.
c. Calibration Module (calibrator.py)
- Provides a calibration routine (and UI prompts) to set camera-related parameters like IP addresses.
d. Processing and Analytics Modules:
- tracker.py: Executes the core computer vision egg detection on the captured frames.
- counter.py: Tallies detected eggs over time.
e. Communication Modules:
- sender.py and ethernetSender.py: Handle the transmission of results (like detection alerts, counts) to external services or monitoring systems.

- Data Flow:
- The camera module captures data that flows into EggWatch.py.
- EggWatch.py may call tracker.py to process each frame and extract detection results.
- The calibrator module (invoked via calibrator.py) may be used to update the configuration in config.ini.
- Counting results (via counter.py) and tracking information pass to the sender modules to notify or log findings.

##### Architectural Patterns and Design Principles
- Modular design: Each script represents a distinct component tasked with a specific function (acquisition, processing, communication), allowing clear separation of concerns.
- Configuration-driven behavior: The use of config.ini suggests that the system uses configuration files to establish runtime parameters.
- Real-Time Processing: The design suggests that there is a continuous, real-time data flow from image capture to egg detection and then to communication modules.

##### Including Technologies and Frameworks
- Python 3 is the language in use.
- OpenCV is essential for image processing.
- Dependencies such as numpy further support numerical computations for the detection algorithms.
- Network communication is handled via custom modules (sender.py, ethernetSender.py) – consider noting protocols or specifics if available.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "EggWatch System Architecture"
        eggwatch["Main Application Controller (EggWatch.py)"]:::controller
        config["Configuration Management (config.ini)"]:::configuration
        camera["Image Acquisition Module (camera.py)"]:::acquisition
        calibrator["Calibration Module (calibrator.py)"]:::calibration
        tracker["Tracking/Processing Module (tracker.py)"]:::processing
        counter["Counting Logic (counter.py)"]:::counting
        sender["Communication Module (sender.py)"]:::communication
        ethernet["Communication Module (ethernetSender.py)"]:::communication
    end

    %% Data Flow and Interactions
    config -->|"loads"| eggwatch
    camera -->|"feedsImageStream"| eggwatch
    eggwatch -->|"initiatesCalibration"| calibrator
    calibrator -->|"updatesConfig"| config
    calibrator -->|"adjustsCameraSettings"| camera
    eggwatch -->|"triggersTracking"| tracker
    tracker -->|"passesDetection"| counter
    counter -->|"sendsResults"| sender
    counter -->|"sendsResults"| ethernet

    %% Styling
    classDef controller fill:#f9d,stroke:#333,stroke-width:2px;
    classDef configuration fill:#ddd,stroke:#333,stroke-width:2px;
    classDef acquisition fill:#cfc,stroke:#333,stroke-width:2px;
    classDef calibration fill:#bbf,stroke:#333,stroke-width:2px;
    classDef processing fill:#fcf,stroke:#333,stroke-width:2px;
    classDef counting fill:#ff9,stroke:#333,stroke-width:2px;
    classDef communication fill:#9cf,stroke:#333,stroke-width:2px;

    %% Click Events
    click eggwatch "https://github.com/baarrii/eggwatch/blob/master/EggWatch.py"
    click calibrator "https://github.com/baarrii/eggwatch/blob/master/calibrator.py"
    click camera "https://github.com/baarrii/eggwatch/blob/master/camera.py"
    click tracker "https://github.com/baarrii/eggwatch/blob/master/tracker.py"
    click counter "https://github.com/baarrii/eggwatch/blob/master/counter.py"
    click sender "https://github.com/baarrii/eggwatch/blob/master/sender.py"
    click ethernet "https://github.com/baarrii/eggwatch/blob/master/ethernetSender.py"
    click config "https://github.com/baarrii/eggwatch/blob/master/config.ini"
```
