# mingshuoxu/small-target-motion-detectors architecture

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

- Interactive diagram: https://gitdiagram.com/mingshuoxu/small-target-motion-detectors
- Repository: https://github.com/mingshuoxu/small-target-motion-detectors

## Overview

##### Main Components
- API Layer – These are the high-level functions that users call (located in the “api” subdirectories in MATLAB and Python, and similar functionality in C++ demos and code).
- Models – Represent the model components that hold the detection models (e.g., ESTMD, DSTMD, FSTMD, and their variants). These are found in their own “model” directories.
- Utilities – Show support modules under “util” which include compute modules, kernel creation functions, I/O handling, visualization tools, and additional helper methods.
- Demo & Test – Separate blocks for demonstration scripts (demo) and testing suites (unit tests) that verify the algorithms.
- Data Handling – Although the core focus is on algorithms, include components for input data sources such as video streams and image files (the “demodata” directory) and designated scripts for launching via MATLAB (“start_by_matlab.m”) and Python (“start_by_python.py”).

##### Reflecting the Multi-Language Implementation
- Optionally, note that the C++ implementation may be used for performance-critical sections and is “synchronized” with the others according to the README.

##### Relationships and Data Flow
- Data Input (videos/images/demodata) → Preprocessing/Utility modules.
- Preprocessing → Core Algorithms and Model Inference.
- Core Algorithms ↔ API Layer (for parameter configuration and abstraction).
- API and Model outputs → Visualization and Evaluation (also part of the demo and util modules).

##### Architectural Patterns and Design Principles
- Modularity: The separation of API, core, models, and util ensures that changes in one part do not affect the others.
- Reusability: Utility modules are decoupled from core logic, and testing is provided to ensure reliability.
- Multi-language Support: Although the project caters to different programming languages, the common directory structure (api, core, model, util, demo, test) indicates a uniform architectural pattern across them.
- Separation of Concerns: Distinct demo and test directories indicate that user interfaces and verification are kept separate from the core detection algorithms.

##### Technologies and Frameworks
- Libraries or functionalities (like kernel functions for convolution, visualization utilities, and matrix processing) should be captured in the UTIL modules.
- Specific features from the README—like advanced algorithm support and parameter configuration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Common Data Handling Node
    DATA["Data Handling - demodata"]:::input

    %% MATLAB Implementation Subgraph
    subgraph "MATLAB Implementation"
        LAUNCH_MATLAB["Launcher - MATLAB"]:::launcher
        API_MATLAB["API Layer - MATLAB"]:::api
        CORE_MATLAB["Core Algorithms - MATLAB"]:::core
        MODEL_MATLAB["Models - MATLAB"]:::model
        UTIL_MATLAB["Utilities - MATLAB"]:::util
        DEMO_MATLAB["Demo Scripts - MATLAB"]:::demo
        TEST_MATLAB["Test Suites - MATLAB"]:::test
    end

    %% Python Implementation Subgraph
    subgraph "Python Implementation"
        LAUNCH_PY["Launcher - Python"]:::launcher
        API_PY["API Layer - Python"]:::api
        CORE_PY["Core Algorithms - Python"]:::core
        MODEL_PY["Models - Python"]:::model
        UTIL_PY["Utilities - Python"]:::util
        DEMO_PY["Demo Scripts - Python"]:::demo
        TEST_PY["Test Suites - Python"]:::test
    end

    %% C++ Implementation Subgraph
    subgraph "C++ Implementation"
        CPP_NODE["C++ Implementation"]:::cpp
    end

    %% Connections for MATLAB Implementation
    LAUNCH_MATLAB -->|"triggers"| API_MATLAB
    UTIL_MATLAB -->|"preprocesses"| CORE_MATLAB
    CORE_MATLAB -->|"applies"| MODEL_MATLAB
    API_MATLAB -->|"visualizes"| DEMO_MATLAB
    MODEL_MATLAB -->|"feeds"| DEMO_MATLAB
    API_MATLAB <-->|"bidirectional"| CORE_MATLAB
    API_MATLAB -->|"tested_by"| TEST_MATLAB
    CORE_MATLAB -->|"tested_by"| TEST_MATLAB
    MODEL_MATLAB -->|"tested_by"| TEST_MATLAB

    %% Data Handling flows into MATLAB Utilities
    DATA -->|"inputs"| UTIL_MATLAB

    %% Connections for Python Implementation
    LAUNCH_PY -->|"triggers"| API_PY
    UTIL_PY -->|"preprocesses"| CORE_PY
    CORE_PY -->|"applies"| MODEL_PY
    API_PY -->|"visualizes"| DEMO_PY
    MODEL_PY -->|"feeds"| DEMO_PY
    API_PY <-->|"bidirectional"| CORE_PY
    API_PY -->|"tested_by"| TEST_PY
    CORE_PY -->|"tested_by"| TEST_PY
    MODEL_PY -->|"tested_by"| TEST_PY

    %% Data Handling flows into Python Utilities
    DATA -->|"inputs"| UTIL_PY

    %% Data Handling flows into C++ Implementation
    DATA -->|"inputs"| CPP_NODE

    %% Click Events for MATLAB Components
    click API_MATLAB "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/matlab/+smalltargetmotiondetectors/+api"
    click CORE_MATLAB "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/matlab/+smalltargetmotiondetectors/+core"
    click MODEL_MATLAB "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/matlab/+smalltargetmotiondetectors/+model"
    click UTIL_MATLAB "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/matlab/+smalltargetmotiondetectors/+util"
    click DEMO_MATLAB "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/matlab/+smalltargetmotiondetectors/demo"
    click TEST_MATLAB "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/matlab/+smalltargetmotiondetectors/test"
    click LAUNCH_MATLAB "https://github.com/mingshuoxu/small-target-motion-detectors/blob/main/start_by_matlab.m"

    %% Click Events for Python Components
    click API_PY "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/python/smalltargetmotiondetectors/api"
    click CORE_PY "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/python/smalltargetmotiondetectors/core"
    click MODEL_PY "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/python/smalltargetmotiondetectors/model"
    click UTIL_PY "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/python/smalltargetmotiondetectors/util"
    click DEMO_PY "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/python/smalltargetmotiondetectors/demo"
    click TEST_PY "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/python/smalltargetmotiondetectors/test"
    click LAUNCH_PY "https://github.com/mingshuoxu/small-target-motion-detectors/blob/main/start_by_python.py"

    %% Click Event for C++ Implementation
    click CPP_NODE "https://github.com/mingshuoxu/small-target-motion-detectors/tree/main/cpp/smalltargetmotiondetectors"

    %% Class Styles
    classDef api fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef core fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef model fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef util fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef demo fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef test fill:#cceeff,stroke:#333,stroke-width:2px;
    classDef launcher fill:#d9d9d9,stroke:#333,stroke-width:2px;
    classDef input fill:#e6e6e6,stroke:#333,stroke-width:2px;
    classDef cpp fill:#ffd699,stroke:#333,stroke-width:2px;
```
