# jiemojiemo/cpp_blind_watermark architecture

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

- Interactive diagram: https://gitdiagram.com/jiemojiemo/cpp_blind_watermark
- Repository: https://github.com/jiemojiemo/cpp_blind_watermark

## Overview

##### Project Type and Purpose
- This is a C/C++ library and demo application that implements the Blind Watermark algorithm.
- It provides a core algorithm module, several utility modules, a command‑line/demo executable, and a suite of unit tests.
- Build and dependency management are handled by Conan and CMake.

##### Main Components
a. Demo Application (Executable)
- main.cpp: entry point that parses inputs, invokes watermarking routines, and displays/saves results.
b. Core Library
- i_blind_watermark_core.h: abstract interface for watermark operations.
- blind_watermark_core0.h: concrete implementation of the blind watermark algorithm.
c. Utility Modules
- base64codec_utils.h / .cpp: Base64 encoding/decoding of watermark payloads.
- binary_utils.h / .cpp: Bit‑level operations for payload embedding/extraction.
- dtw2_utils.h / .cpp: Dynamic Time Warping utilities if used in the algorithm pipeline.
d. Third‑Party Libraries
- 3rdparty/wavelib: wavelet transform routines referenced by the core algorithm.
- External deps (via Conan): OpenCV 4.x for image/video I/O and processing; base64/0.5.1, etc.
e. Test Suite
- tests/*: GoogleTest‑based unit tests for each utility and the core algorithm.
f. Build System
- conanfile.txt: dependency declarations.
- CMakeLists.txt + 3rdparty/CMakeLists.txt: build scripts.

##### Component Relationships & Data Flow
- The Demo Application calls the Core Library API.
- The Core Library orchestrates:
· wavelet transforms (wavelib)
· bit manipulation (binary_utils)
· Base64 encoding/decoding (base64codec_utils)
· DTW computations (dtw2_utils)
- External libraries (OpenCV, base64) are linked at build time via Conan/CMake.
- The Test Suite links against the Core and Utility modules to verify correctness.

##### Architectural Patterns & Design Principles
- Modular monolith: clear separation between interface (i_blind_watermark_core) and implementation.
- Layered organization: Demo → Core → Utilities → Third‑party.
- Dependency injection: Core interface allows swapping algorithm versions.
- Unit‑testable design: small, focused modules with GoogleTest harnesses.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Demo Application
    DemoApp["Demo Application\n(main.cpp)"]:::code
    %% Core Library
    subgraph "Core Library"
        direction TB
        IBlind["i_blind_watermark_core\n(include/i_blind_watermark_core.h)"]:::core
        CoreImpl["blind_watermark_core0\n(include/blind_watermark_core0.h)"]:::core
    end
    %% Utility Modules
    subgraph "Utilities"
        direction LR
        Base64["Base64 Codec\n(include/base64codec_utils.h)"]:::util
        Binary["Binary Ops\n(include/binary_utils.h)"]:::util
        DTW["DTW Utils\n(include/dtw2_utils.h)"]:::util
    end
    %% External Libraries
    subgraph "External Libraries"
        direction TB
        Wavelib(("wavelib")):::external
        OpenCV(("OpenCV 4.x")):::external
        ExtBase64(("base64/0.5.1")):::external
    end
    %% Build System
    subgraph "Build System"
        direction TB
        Conan["Conan\n(conanfile.txt)"]:::build
        CMakeRoot["CMake Root\n(CMakeLists.txt)"]:::build
        CMake3rd["3rd-Party CMake\n(3rdparty/CMakeLists.txt)"]:::build
    end
    %% Test Suite
    subgraph "Test Suite"
        direction TB
        TestsDir["tests/"]:::test
        T1["test_base64_codec_utils.cpp"]:::test
        T2["test_binary_utils.cpp"]:::test
        T3["test_bind_watermark_core0.cpp"]:::test
        T4["test_wavelet_utils.cpp"]:::test
    end

    %% Layout
    DemoApp -->|"calls"| IBlind
    IBlind -->|"implements"| CoreImpl
    CoreImpl -->|"uses"| Wavelib
    CoreImpl -->|"calls"| Binary
    CoreImpl -->|"calls"| Base64
    CoreImpl -->|"calls"| DTW
    Base64 -->|"link"| ExtBase64
    DemoApp -.->|"link"| OpenCV

    %% Build arrows
    Conan -.-> CMakeRoot
    CMakeRoot -.-> CMake3rd
    CMake3rd -.-> DemoApp
    CMake3rd -.-> CoreImpl
    CMake3rd -.-> Base64
    CMake3rd -.-> Binary
    CMake3rd -.-> DTW

    %% Test links
    TestsDir --> T1
    TestsDir --> T2
    TestsDir --> T3
    TestsDir --> T4
    T1 -->|tests| Base64
    T2 -->|tests| Binary
    T3 -->|tests| CoreImpl
    T4 -->|tests| Wavelib

    %% Click events
    click DemoApp "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/main.cpp"
    click IBlind "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/include/i_blind_watermark_core.h"
    click CoreImpl "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/include/blind_watermark_core0.h"
    click Base64 "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/include/base64codec_utils.h"
    click Binary "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/include/binary_utils.h"
    click DTW "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/include/dtw2_utils.h"
    click Wavelib "https://github.com/jiemojiemo/cpp_blind_watermark/tree/main/3rdparty/wavelib"
    click Conan "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/conanfile.txt"
    click CMakeRoot "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/CMakeLists.txt"
    click CMake3rd "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/3rdparty/CMakeLists.txt"
    click TestsDir "https://github.com/jiemojiemo/cpp_blind_watermark/tree/main/tests/"
    click T1 "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/tests/test_base64_codec_utils.cpp"
    click T2 "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/tests/test_binary_utils.cpp"
    click T3 "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/tests/test_bind_watermark_core0.cpp"
    click T4 "https://github.com/jiemojiemo/cpp_blind_watermark/blob/main/tests/test_wavelet_utils.cpp"

    %% Styles
    classDef code fill:#f9f,stroke:#333,stroke-width:1px;
    classDef core fill:#bbf,stroke:#333,stroke-width:1px;
    classDef util fill:#bfb,stroke:#333,stroke-width:1px;
    classDef external fill:#fb8,stroke:#333,stroke-width:1px,shape:cylinder;
    classDef build stroke-dasharray: 5 5,fill:#ddd,stroke:#666,stroke-width:1px;
    classDef test fill:#fbb,stroke:#333,stroke-width:1px;
```
