# siftsharp/moneyrecognition architecture

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

- Interactive diagram: https://gitdiagram.com/siftsharp/moneyrecognition
- Repository: https://github.com/siftsharp/moneyrecognition

## Overview

##### Main Components

a. Input Layer:
- Camera Capture System (represented by Capture.cs)
- Image Input Processing (Image.cs, LockBitmap.cs)

b. Core SIFT Processing Layer:
- SIFT Implementation (SIFT folder)
- Feature Detection (Feature.cs)
- Interpolation Processing (Interpolation.cs)
- SIFT Algorithm Core (Sift.cs)
- Persistence Management (Persist.cs)

c. User Interface Layer:
- Windows Forms Interface (MainWindow.cs)

d. External Dependencies:
- DirectShowNet (for camera capture)
- Supercluster.KDTree (for feature matching)
- Testing Framework (NUnit)

**[User Interface Layer]**
- ↑↓
**[Input Processing Layer]**
- ↑↓
**[SIFT Processing Layer]**
- ↑↓
**[Data Storage/Persistence]**

##### Specific Implementation Details

a. Data Flow:
- Image capture → Image processing → SIFT analysis → Money recognition result
- How the reference images (in /images/data/) are used for comparison

b. Component Interaction:
- How MainWindow.cs coordinates between capture and SIFT processing
- Relationship between Feature.cs and Sift.cs
- Demonstrate how Persist.cs handles data storage

##### Key Architectural Patterns to Highlight

- Separation between UI, business logic, and image processing
- Modular nature of the SIFT implementation
- Testing architecture (Tests folder structure)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        MW["Main Window"]:::ui
        MWD["Window Designer"]:::ui
    end

    subgraph Input["Input Processing Layer"]
        CC["Camera Capture"]:::input
        IP["Image Processing"]:::input
        LB["Lock Bitmap"]:::input
    end

    subgraph SIFT["SIFT Processing Layer"]
        FD["Feature Detection"]:::sift
        IP2["Interpolation"]:::sift
        SC["SIFT Core"]:::sift
        DU["Drawing Utilities"]:::sift
        PM["Persistence Manager"]:::sift
    end

    subgraph Storage["Data Storage Layer"]
        RD["Reference Data"]:::storage
        subgraph Denominations
            D1["$1"]:::storage
            D5["$5"]:::storage
            D10["$10"]:::storage
            D20["$20"]:::storage
            D50["$50"]:::storage
            D100["$100"]:::storage
        end
    end

    subgraph Testing["Testing Framework"]
        IT["Image Tests"]:::test
        PT["Persist Tests"]:::test
        ST["SIFT Tests"]:::test
    end

    subgraph External["External Dependencies"]
        DS["DirectShowNet"]:::external
        KD["Supercluster.KDTree"]:::external
        NU["NUnit"]:::external
    end

    %% Relationships
    MW --> CC
    MW --> IP
    CC --> IP
    IP --> LB
    IP --> SC
    SC --> FD
    SC --> IP2
    SC --> DU
    SC --> PM
    PM --> RD
    RD --> D1 & D5 & D10 & D20 & D50 & D100

    %% Testing relationships
    IT --> IP
    PT --> PM
    ST --> SC

    %% External Dependencies
    CC --> DS
    FD --> KD
    Testing --> NU

    %% Click events
    click MW "https://github.com/SiftSharp/moneyRecognition/blob/master/SiftSharp/MainWindow.cs"
    click MWD "https://github.com/SiftSharp/moneyRecognition/blob/master/SiftSharp/MainWindow.Designer.cs"
    click CC "https://github.com/SiftSharp/moneyRecognition/blob/master/SiftSharp/Capture.cs"
    click IP "https://github.com/SiftSharp/moneyRecognition/blob/master/SiftSharp/Image.cs"
    click LB "https://github.com/SiftSharp/moneyRecognition/blob/master/SiftSharp/LockBitmap.cs"
    click FD "https://github.com/SiftSharp/moneyRecognition/blob/master/SiftSharp/SIFT/Feature.cs"
    click IP2 "https://github.com/SiftSharp/moneyRecognition/blob/master/SiftSharp/SIFT/Interpolation.cs"
    click SC "https://github.com/SiftSharp/moneyRecognition/blob/master/SiftSharp/SIFT/Sift.cs"
    click DU "https://github.com/SiftSharp/moneyRecognition/blob/master/SiftSharp/SIFT/Draw.cs"
    click PM "https://github.com/SiftSharp/moneyRecognition/blob/master/SiftSharp/SIFT/Persist.cs"
    click IT "https://github.com/SiftSharp/moneyRecognition/blob/master/Tests/ImageTests.cs"
    click PT "https://github.com/SiftSharp/moneyRecognition/blob/master/Tests/SIFT/PersistTests.cs"
    click ST "https://github.com/SiftSharp/moneyRecognition/blob/master/Tests/SIFT/SiftTests.cs"
    click D1 "https://github.com/SiftSharp/moneyRecognition/tree/master/images/data/1"
    click D5 "https://github.com/SiftSharp/moneyRecognition/tree/master/images/data/5"
    click D10 "https://github.com/SiftSharp/moneyRecognition/tree/master/images/data/10"
    click D20 "https://github.com/SiftSharp/moneyRecognition/tree/master/images/data/20"
    click D50 "https://github.com/SiftSharp/moneyRecognition/tree/master/images/data/50"
    click D100 "https://github.com/SiftSharp/moneyRecognition/tree/master/images/data/100"

    %% Styling
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef input fill:#2ecc71,stroke:#27ae60,color:white
    classDef sift fill:#f1c40f,stroke:#f39c12,color:black
    classDef storage fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef test fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Input Processing"]:::input
        L3["SIFT Processing"]:::sift
        L4["Storage"]:::storage
        L5["External Dependencies"]:::external
        L6["Testing"]:::test
    end
```
