# shreejan-git/wildanimals_detection architecture

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

- Interactive diagram: https://gitdiagram.com/shreejan-git/wildanimals_detection
- Repository: https://github.com/shreejan-git/wildanimals_detection

## Overview

This is a from-scratch YOLO object-detection application whose documented entry point processes video. The workflow reads video frames, resizes and tensors each frame, runs a configuration-built detector, decodes and filters boxes, then annotates the frame; elephant detections below a horizontal threshold can trigger serial output. The excerpts show the model, preprocessing, and postprocessing calls. Other detector capabilities are represented at subsystem level; unsampled files are not assumed to participate.

Main entry points: [`detect_video.py`](https://github.com/shreejan-git/wildanimals_detection/blob/master/detect_video.py) (Video detector), [`DNModel.py`](https://github.com/shreejan-git/wildanimals_detection/blob/master/DNModel.py) (Darknet model), [`img_process.py`](https://github.com/shreejan-git/wildanimals_detection/blob/master/img_process.py) (Aspect resize), [`cfg`](https://github.com/shreejan-git/wildanimals_detection/tree/master/cfg) (YOLO configurations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Video input"]
  node_runner["Video detector<br/>[detect_video.py]"]
  node_preprocess["Frame preprocessing<br/>[detect_video.py]"]
  node_resize["Aspect resize<br/>[img_process.py]"]
end

subgraph group_inference["YOLO inference"]
  node_cfg["YOLO configurations"]
  node_model["Darknet model<br/>[DNModel.py]"]
  node_decode["Output decoding<br/>[util.py]"]
end

subgraph group_results["Detection results"]
  node_postprocess["Box filtering and NMS<br/>[util.py]"]
end

subgraph group_outputs["Display and signaling"]
  node_annotate["Detection annotation<br/>[detect_video.py]"]
  node_display["Video display<br/>[detect_video.py]"]
end

node_user(("Operator"))
node_video["Video source"]
node_serial["Serial device"]

node_user -->|"runs"| node_runner
node_video -->|"provides frames"| node_runner
node_runner -->|"prepares frame"| node_preprocess
node_preprocess -->|"resizes via"| node_resize
node_runner -->|"runs inference"| node_model
node_model -->|"reads configuration"| node_cfg
node_model -->|"decodes predictions"| node_decode
node_runner -->|"filters boxes"| node_postprocess
node_runner -->|"annotates detections"| node_annotate
node_runner -->|"displays frames"| node_display
node_annotate -->|"signals detection"| node_serial

click node_runner "https://github.com/shreejan-git/wildanimals_detection/blob/master/detect_video.py"
click node_preprocess "https://github.com/shreejan-git/wildanimals_detection/blob/master/detect_video.py"
click node_resize "https://github.com/shreejan-git/wildanimals_detection/blob/master/img_process.py"
click node_cfg "https://github.com/shreejan-git/wildanimals_detection/tree/master/cfg"
click node_model "https://github.com/shreejan-git/wildanimals_detection/blob/master/DNModel.py"
click node_decode "https://github.com/shreejan-git/wildanimals_detection/blob/master/util.py"
click node_postprocess "https://github.com/shreejan-git/wildanimals_detection/blob/master/util.py"
click node_annotate "https://github.com/shreejan-git/wildanimals_detection/blob/master/detect_video.py"
click node_display "https://github.com/shreejan-git/wildanimals_detection/blob/master/detect_video.py"

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_runner,node_preprocess,node_resize toneBlue
class node_cfg,node_model,node_decode toneAmber
class node_postprocess toneMint
class node_annotate,node_display toneRose
class node_user,node_video,node_serial toneIndigo
```

## Components

### Video input

- [Video detector](https://github.com/shreejan-git/wildanimals_detection/blob/master/detect_video.py): `detect_video.py`
- [Frame preprocessing](https://github.com/shreejan-git/wildanimals_detection/blob/master/detect_video.py): `detect_video.py`
- [Aspect resize](https://github.com/shreejan-git/wildanimals_detection/blob/master/img_process.py): `img_process.py`

### YOLO inference

- [YOLO configurations](https://github.com/shreejan-git/wildanimals_detection/tree/master/cfg): `cfg`
- [Darknet model](https://github.com/shreejan-git/wildanimals_detection/blob/master/DNModel.py): `DNModel.py`
- [Output decoding](https://github.com/shreejan-git/wildanimals_detection/blob/master/util.py): `util.py`

### Detection results

- [Box filtering and NMS](https://github.com/shreejan-git/wildanimals_detection/blob/master/util.py): `util.py`

### Display and signaling

- [Detection annotation](https://github.com/shreejan-git/wildanimals_detection/blob/master/detect_video.py): `detect_video.py`
- [Video display](https://github.com/shreejan-git/wildanimals_detection/blob/master/detect_video.py): `detect_video.py`

### Other components

- **Operator**
- **Video source**
- **Serial device**

## Connections

- Operator → Video detector: runs (evidence: `README.md`)
- Video source → Video detector: provides frames (evidence: `detect_video.py`)
- Video detector → Frame preprocessing: prepares frame (evidence: `detect_video.py`)
- Frame preprocessing → Aspect resize: resizes via (evidence: `detect_video.py`)
- Video detector → Darknet model: runs inference (evidence: `detect_video.py`)
- Darknet model → YOLO configurations: reads configuration (evidence: `DNModel.py`)
- Darknet model → Output decoding: decodes predictions (evidence: `DNModel.py`)
- Video detector → Box filtering and NMS: filters boxes (evidence: `detect_video.py`)
- Video detector → Detection annotation: annotates detections (evidence: `detect_video.py`)
- Video detector → Video display: displays frames (evidence: `detect_video.py`)
- Detection annotation → Serial device: signals detection (evidence: `detect_video.py`)
