Skip to content

Commit f6049c3

Browse files
Update README.md of Controller
1 parent 2bf555f commit f6049c3

1 file changed

Lines changed: 56 additions & 30 deletions

File tree

Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# ⚙️ Controllers Module (Logic Layer)
22

3-
This directory contains the business logic of the **SoccerNet Pro Annotation Tool**.
4-
Following the **MVC (Model-View-Controller)** architecture, these scripts act as the bridge between the data (`models.py`) and the interface (`ui/`). They handle user input, data processing, file I/O, and application state management.
3+
This directory contains the business logic of the **SoccerNet Pro Annotation Tool**. following the **MVC (Model-View-Controller)** architecture, these scripts act as the bridge between the data (`models.py`) and the interface (`ui/`). They handle user input, data processing, file I/O, and application state management.
54

65
## 📂 Directory Structure
76

87
```text
98
controllers/
9+
├── media_controller.py # [NEW] Unified Video Playback Manager
1010
├── history_manager.py # Universal Undo/Redo logic
1111
├── router.py # Application routing and mode switching
1212
├── classification/ # Logic specific to Whole-Video Classification
13-
└── localization/ # Logic specific to Action Spotting (Localization)
13+
├── localization/ # Logic specific to Action Spotting (Timestamps)
14+
├── description/ # Logic specific to Global Captioning (Text)
15+
└── dense_description/ # Logic specific to Dense Captioning (Timestamped Text)
1416
1517
```
1618

@@ -20,23 +22,33 @@ controllers/
2022

2123
### 1. Core Controllers (Root)
2224

23-
These controllers provide foundational functionality used across the entire application.
25+
These controllers provide foundational functionality used across the entire application to ensure stability and consistency.
26+
27+
* **`media_controller.py`**
28+
* **Role**: The centralized video playback engine used by all modes.
29+
* **Responsibilities**:
30+
* **Robust State Management**: Implements a strict `Stop -> Clear -> Load -> Delay -> Play` sequence to prevent black screens and buffer artifacts.
31+
* **Race Condition Prevention**: Uses an internal `QTimer` that is explicitly cancelled upon stop, preventing videos from starting in the background after a user has closed a project.
32+
* **Visual Clearing**: Forces the `QVideoWidget` to repaint/update on stop, ensuring no "stuck frames" remain visible.
33+
34+
35+
2436

2537
* **`router.py`**
2638
* **Role**: The "Traffic Cop" of the application.
2739
* **Responsibilities**:
28-
* Handles the "Create Project" and "Load Project" flows.
29-
* Analyzes input JSON files to determine if the project is **Classification** or **Localization**.
30-
* Initializes the appropriate specific managers and switches the UI view accordingly.
40+
* Handles the "Create Project" and "Load Project" flows.
41+
* Analyzes input JSON files (keys like `events`, `captions`, `labels`) to automatically detect the project mode.
42+
* Initializes the appropriate specific managers and switches the UI view.
3143

3244

3345

3446

3547
* **`history_manager.py`**
3648
* **Role**: The "Time Machine" (Undo/Redo System).
3749
* **Responsibilities**:
38-
* Implements the **Command Pattern** to manage the Undo/Redo stacks in `AppStateModel`.
39-
* Executes undo/redo operations and triggers the necessary UI refreshes (`_refresh_active_view`) depending on whether the user is in Classification or Localization mode.
50+
* Implements the **Command Pattern** to manage the Undo/Redo stacks in `AppStateModel`.
51+
* Executes operations and triggers the necessary UI refreshes (`_refresh_active_view`) for all four modes.
4052

4153

4254

@@ -46,35 +58,49 @@ These controllers provide foundational functionality used across the entire appl
4658

4759
Logic dedicated to the **Whole-Video Classification** task (assigning attributes to an entire video clip).
4860

49-
* **`class_file_manager.py`**
50-
* Handles JSON I/O for classification projects.
51-
* Manages relative path calculations for portability.
52-
* Resets the workspace when closing projects.
61+
* **`class_file_manager.py`**: Handles JSON I/O and relative path calculations.
62+
* **`navigation_manager.py`**: Manages the "Action List" (Left Panel), auto-play logic, and filtering.
63+
* **`annotation_manager.py`**: Manages dynamic schema logic (Radio/Checkbox generation) and saves class selections.
64+
65+
### 3. Localization Controllers (`controllers/localization/`)
5366

67+
Logic dedicated to the **Action Spotting** task (pinpointing specific timestamps).
5468

55-
* **`navigation_manager.py`**
56-
* Manages the "Action List" (Left Panel) interactions.
57-
* Handles video playback flow, including auto-playing the next video and filtering the list (Done/Not Done).
69+
* **`loc_file_manager.py`**: Handles JSON I/O with path fallback logic (checking local directories if absolute paths fail).
70+
* **`localization_manager.py`**:
71+
* Synchronizes the **Video Player**, **Timeline Widget**, and **Event Table**.
72+
* Captures timestamps for spotting events and manages the multi-tab interface.
5873

5974

60-
* **`annotation_manager.py`**
61-
* Manages the dynamic schema logic (adding/removing Label Heads and Label Options).
62-
* Processes user input from the Right Panel and saves annotations to the `AppStateModel`.
6375

76+
### 4. Description Controllers (`controllers/description/`) [NEW]
6477

78+
Logic dedicated to the **Global Captioning** task (one text description per video action).
6579

66-
### 3. Localization Controllers (`controllers/localization/`)
80+
* **`desc_navigation_manager.py`**:
81+
* Manages **Multi-Clip Actions** (navigating logical "Actions" that may contain multiple video files).
82+
* Wraps the `MediaController` to ensure smooth loading of large video files.
83+
84+
85+
* **`desc_annotation_manager.py`**:
86+
* Handles **Q&A Formatting**: Parses JSON "questions" into a readable Q&A format in the editor.
87+
* **Flattening**: Consolidates text into a single description block upon save.
88+
89+
90+
* **`desc_file_manager.py`**:
91+
* Manages JSON I/O specific to the captioning schema, ensuring `inputs` and `captions` fields are preserved correctly.
92+
93+
94+
95+
### 5. Dense Description Controllers (`controllers/dense_description/`) [NEW]
6796

68-
Logic dedicated to the **Action Spotting** task (pinpointing specific timestamps within a video).
97+
Logic dedicated to the **Dense Captioning** task (text descriptions anchored to specific timestamps).
6998

70-
* **`loc_file_manager.py`**
71-
* Handles JSON I/O for localization projects.
72-
* Includes **Path Fallback** logic: if an absolute path in the JSON is missing, it attempts to find the video in the local directory to support cross-device collaboration.
99+
* **`dense_manager.py`**:
100+
* **Editor-Timeline Sync**: Continuously synchronizes the text input field with the video playback position. If the video hits an event, the text loads automatically.
101+
* **CRUD**: Handles creating, updating, and deleting timestamped text events.
73102

74103

75-
* **`localization_manager.py`**
76-
* **Role**: The central hub for the Localization UI.
77-
* **Responsibilities**:
78-
* Synchronizes the **Video Player**, **Timeline Widget**, and **Event Table**.
79-
* Captures timestamps when users trigger a spotting event.
80-
* Manages the Multi-Tab interface for different event categories.
104+
* **`dense_file_manager.py`**:
105+
* **Metadata Preservation**: Ensures global and item-level metadata is retained during Load/Save cycles.
106+
* **Data Mapping**: Maps the flat `dense_captions` JSON list to the internal application model.

0 commit comments

Comments
 (0)