# happy95059/computer_vision_hw1 architecture

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

- Interactive diagram: https://gitdiagram.com/happy95059/computer_vision_hw1
- Repository: https://github.com/happy95059/computer_vision_hw1

## Overview

##### Project type and purpose
- This is a small, modular, Python-based computer-vision toolset (a “homework1” assignment) that processes short video clips to detect and replace objects (coin, poker card, dice) against a predicted background.

##### File structure
- Top-level:
- 61175069H_a1/source/
– hw1-1/
· get_background.py (background-capture utility)
· hw1-1_coint.py (main coin-removal script)
– hw1-2/
· poker_matting.py (card matting helper)
· hw1-2_poker.py (main card-replacement script)
– hw1-3/
· dice_matting.py (dice matting helper)
· hw1-3_dice.py (main dice-replacement script)
– test.py (generic test harness for all HWI scripts)
- Three .mp4 videos (hw1-1.mp4, hw1-2.mp4, hw1-3.mp4) used as inputs
- No external microservices or databases; all is on local file I/O and in-memory OpenCV processing.

##### README for additional insights
- Lists custom functions (get_hand_direction, get_origin_color, change_color2background, get_coint_direction, show_edge) that form the reusable CV library.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Input Videos
    subgraph "Input Videos"
        hw1_1_mp4["hw1-1.mp4"]:::input
        hw1_2_mp4["hw1-2.mp4"]:::input
        hw1_3_mp4["hw1-3.mp4"]:::input
    end

    %% Homework 1 Suite
    subgraph "Homework 1 Suite"
        subgraph "Coin Removal" 
            coin_orch["hw1-1_coint.py"]:::orchestrator
            bg_util["get_background.py"]:::helper
        end
        subgraph "Poker Replacement"
            poker_orch["hw1-2_poker.py"]:::orchestrator
            poker_mat["poker_matting.py"]:::helper
        end
        subgraph "Dice Replacement"
            dice_orch["hw1-3_dice.py"]:::orchestrator
            dice_mat["dice_matting.py"]:::helper
        end
    end

    %% Outputs
    processed1["Processed Video (Coin)"]:::output
    processed2["Processed Video (Poker)"]:::output
    processed3["Processed Video (Dice)"]:::output

    %% Test Harness
    test_harness["test.py"]:::test

    %% Data Flows
    hw1_1_mp4 -->|"frames"| coin_orch
    coin_orch -->|"background frames"| bg_util
    bg_util -->|"background model"| coin_orch
    coin_orch -->|"blended frames"| processed1

    hw1_2_mp4 -->|"frames"| poker_orch
    poker_orch -->|"mask generation"| poker_mat
    poker_mat -->|"alpha matte"| poker_orch
    poker_orch -->|"blended frames"| processed2

    hw1_3_mp4 -->|"frames"| dice_orch
    dice_orch -->|"mask generation"| dice_mat
    dice_mat -->|"alpha matte"| dice_orch
    dice_orch -->|"blended frames"| processed3

    test_harness -->|"run coin flow"| coin_orch
    test_harness -->|"run poker flow"| poker_orch
    test_harness -->|"run dice flow"| dice_orch

    %% Click Events
    click hw1_1_mp4 "https://github.com/happy95059/computer_vision_hw1/blob/main/61175069H_a1/source/hw1-1.mp4"
    click hw1_2_mp4 "https://github.com/happy95059/computer_vision_hw1/blob/main/61175069H_a1/source/hw1-2.mp4"
    click hw1_3_mp4 "https://github.com/happy95059/computer_vision_hw1/blob/main/61175069H_a1/source/hw1-3.mp4"

    click coin_orch "https://github.com/happy95059/computer_vision_hw1/blob/main/61175069H_a1/source/hw1-1/hw1-1_coint.py"
    click poker_orch "https://github.com/happy95059/computer_vision_hw1/blob/main/61175069H_a1/source/hw1-2/hw1-2_poker.py"
    click dice_orch "https://github.com/happy95059/computer_vision_hw1/blob/main/61175069H_a1/source/hw1-3/hw1-3_dice.py"

    click bg_util "https://github.com/happy95059/computer_vision_hw1/blob/main/61175069H_a1/source/hw1-1/get_background.py"
    click poker_mat "https://github.com/happy95059/computer_vision_hw1/blob/main/61175069H_a1/source/hw1-2/poker_matting.py"
    click dice_mat "https://github.com/happy95059/computer_vision_hw1/blob/main/61175069H_a1/source/hw1-3/dice_matting.py"

    click test_harness "https://github.com/happy95059/computer_vision_hw1/blob/main/61175069H_a1/source/test.py"

    %% Styles
    classDef input fill:#1E90FF,stroke:#333,color:#fff
    classDef orchestrator fill:#32CD32,stroke:#333
    classDef helper fill:#FFA500,stroke:#333
    classDef output fill:#1E90FF,stroke:#333,color:#fff
    classDef test fill:#D3D3D3,stroke:#333,stroke-dasharray: 5 5
```
