# megatran/emotionrecognitiononhologram architecture

> Architecture diagram of the GitHub repository megatran/emotionrecognitiononhologram, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/megatran/emotionrecognitiononhologram
- Repository: https://github.com/megatran/emotionrecognitiononhologram

## Overview

This is a webcam facial-expression recognition system whose predicted emotion is sent to a Unity character for animated display in a DIY pyramid hologram. The visible Python workflow captures video, detects and resizes faces, classifies them with a CNN, and posts emotion data; separate scripts prepare datasets and train or evaluate models. Unity-side paths show the HTTP server, emotion-processing, serialization, and shape-management components, but their interactions are not excerpted. Dashed links mark documented or plausible integration points whose Unity-side wiring could not be verified.

Main entry points: [`cv-deeplearning/predictModel.py`](https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/predictModel.py) (Live prediction), [`EmotionalExpressionUnity/Assets/WebServer/SimpleHttpServer.cs`](https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/WebServer/SimpleHttpServer.cs) (HTTP server), [`EmotionalExpressionUnity/Assets/EmotionProcessor.cs`](https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/EmotionProcessor.cs) (Emotion processor), [`cv-deeplearning/imageDataExtract.py`](https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/imageDataExtract.py) (Face data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Vision and prediction"]
  node_predict["Live prediction<br/>[predictModel.py]"]
  node_faces["Face data"]
end

subgraph group_ml["Model development"]
  node_training["CNN training<br/>[model.py]"]
  node_evaluation["Model evaluation<br/>[load-model.py]"]
end

subgraph group_unity["Unity expression"]
  node_server["HTTP server"]
  node_response["HTTP response<br/>[SimpleResponse.cs]"]
  node_processor["Emotion processor"]
  node_json["Emotion JSON<br/>[EmotionJson.cs]"]
  node_state["Emotion state<br/>[EmotionData.cs]"]
  node_shapes["Shape management<br/>[ShapeManagement.cs]"]
  node_character["Unity character<br/>[ShapeKeys.prefab]"]
  node_hologram["Hologram display"]
end

subgraph group_prep["Dataset preparation"]
  node_capture["Sample capture<br/>[photoCapture.py]"]
  node_crop["Image cropping<br/>[image_cropper.py]"]
  node_resize["Image resizing<br/>[image_resize.py]"]
  node_grayscale["Gray conversion<br/>[convertToGray.py]"]
end

node_user(("Operator"))
node_webcam["Webcam"]

node_user -->|"starts capture"| node_predict
node_webcam -->|"provides frames"| node_predict
node_predict -->|"imports data module"| node_faces
node_user -->|"directs sampling"| node_capture
node_training -->|"loads datasets"| node_faces
node_evaluation -->|"loads matrices"| node_faces
node_predict -.->|"posts emotion"| node_server
node_server -.->|"uses response"| node_response
node_server -.->|"dispatches emotion"| node_processor
node_processor -.->|"decodes data"| node_json
node_processor -.->|"updates state"| node_state
node_state -.->|"drives expression"| node_shapes
node_shapes -.->|"animates"| node_character
node_character -.->|"displays in scene"| node_hologram

click node_predict "https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/predictModel.py"
click node_faces "https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/imageDataExtract.py"
click node_training "https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/model.py"
click node_evaluation "https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/load-model.py"
click node_capture "https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/photoCapture.py"
click node_crop "https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/dataTools/image_cropper.py"
click node_resize "https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/dataTools/image_resize.py"
click node_grayscale "https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/dataTools/convertToGray.py"
click node_server "https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/WebServer/SimpleHttpServer.cs"
click node_response "https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/WebServer/SimpleResponse.cs"
click node_processor "https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/EmotionProcessor.cs"
click node_json "https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/EmotionJson.cs"
click node_state "https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/EmotionData.cs"
click node_shapes "https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/ShapeManagement.cs"
click node_character "https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/ShapeKeys.prefab"
click node_hologram "https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/facialExpressionDemo.unity"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_predict,node_faces toneBlue
class node_training,node_evaluation toneAmber
class node_server,node_response,node_processor,node_json,node_state,node_shapes,node_character,node_hologram toneMint
class node_capture,node_crop,node_resize,node_grayscale toneRose
class node_user,node_webcam toneIndigo
```

## Components

### Vision and prediction

- [Live prediction](https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/predictModel.py): `cv-deeplearning/predictModel.py`
- [Face data](https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/imageDataExtract.py): `cv-deeplearning/imageDataExtract.py`

### Model development

- [CNN training](https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/model.py): `cv-deeplearning/model.py`
- [Model evaluation](https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/load-model.py): `cv-deeplearning/load-model.py`

### Unity expression

- [HTTP server](https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/WebServer/SimpleHttpServer.cs): `EmotionalExpressionUnity/Assets/WebServer/SimpleHttpServer.cs`
- [HTTP response](https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/WebServer/SimpleResponse.cs): `EmotionalExpressionUnity/Assets/WebServer/SimpleResponse.cs`
- [Emotion processor](https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/EmotionProcessor.cs): `EmotionalExpressionUnity/Assets/EmotionProcessor.cs`
- [Emotion JSON](https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/EmotionJson.cs): `EmotionalExpressionUnity/Assets/EmotionJson.cs`
- [Emotion state](https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/EmotionData.cs): `EmotionalExpressionUnity/Assets/EmotionData.cs`
- [Shape management](https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/ShapeManagement.cs): `EmotionalExpressionUnity/Assets/ShapeManagement.cs`
- [Unity character](https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/ShapeKeys.prefab): `EmotionalExpressionUnity/Assets/ShapeKeys.prefab`
- [Hologram display](https://github.com/megatran/emotionrecognitiononhologram/blob/master/EmotionalExpressionUnity/Assets/facialExpressionDemo.unity): `EmotionalExpressionUnity/Assets/facialExpressionDemo.unity`

### Dataset preparation

- [Sample capture](https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/photoCapture.py): `cv-deeplearning/photoCapture.py`
- [Image cropping](https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/dataTools/image_cropper.py): `cv-deeplearning/dataTools/image_cropper.py`
- [Image resizing](https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/dataTools/image_resize.py): `cv-deeplearning/dataTools/image_resize.py`
- [Gray conversion](https://github.com/megatran/emotionrecognitiononhologram/blob/master/cv-deeplearning/dataTools/convertToGray.py): `cv-deeplearning/dataTools/convertToGray.py`

### Other components

- **Operator**
- **Webcam**

## Connections

- Operator → Live prediction: starts capture (evidence: `README.md`)
- Webcam → Live prediction: provides frames (evidence: `cv-deeplearning/predictModel.py`)
- Live prediction → Face data: imports data module (evidence: `cv-deeplearning/predictModel.py`)
- Operator → Sample capture: directs sampling (evidence: `cv-deeplearning/photoCapture.py`)
- CNN training → Face data: loads datasets (evidence: `cv-deeplearning/model.py`)
- Model evaluation → Face data: loads matrices (evidence: `cv-deeplearning/load-model.py`)
- Live prediction → HTTP server: posts emotion
- HTTP server → HTTP response: uses response
- HTTP server → Emotion processor: dispatches emotion
- Emotion processor → Emotion JSON: decodes data
- Emotion processor → Emotion state: updates state
- Emotion state → Shape management: drives expression
- Shape management → Unity character: animates
- Unity character → Hologram display: displays in scene
