Architecture๏
MIRA is built with a modular asynchronous architecture using Python and PyQt5. This design ensures that the user interface remains responsive even during heavy YOLO inference or high-resolution video capture.
mira/
โโโ main.py # Application entry point & theme detection
โโโ main_window.py # Main UI controller (Signal/Slot coordination)
โโโ camera_worker.py # Multi-threaded camera management
โโโ camera_config_manager.py # Camera profiles (save/load/default)
โโโ detection_engine.py # AI logic (YOLO inference & tracking)
โโโ data_manager.py # Data persistence & Excel generation
โโโ widgets.py # Reusable custom UI components
โโโ style_dark.qss # Dark theme stylesheet
โโโ style_light.qss # Light theme stylesheet
โโโ trackers/ # Tracker configs (BotSORT/ByteTrack)
โ
Core Components๏
Main UI Logic (main_window.py)
Acts as the orchestrator of the application. It handles user interactions, manages the state of the UI, and routes signals between the camera thread and the detection engine.
Async Processing (camera_worker.py)
Runs in a dedicated thread to prevent UI freezing. It handles the OpenCV video stream, applies real-time image adjustments (gain, zoom), and emits frames for display.
AI Inference (detection_engine.py)
Wraps the Ultralytics YOLO model. It performs object detection, calculates surface areas, and applies temporal averaging algorithms to ensure count stability.
Data & Export (data_manager.py)
Responsible for organizing images into the directory structure and generating the multi-sheet Excel reports using Pandas and OpenPyXL.
โ
Custom UI Elements๏
MIRA features several specialized widgets built from scratch to meet microscopy needs:
Widget Name |
Purpose |
|---|---|
|
Interactive graphical representation of Malassez/KOVA grids. |
|
A modern animated toggle switch for Detection and Camera states. |
|
Real-time table display for class-wise detection counts. |
|
Themed logging console with color-coded severity levels. |
โ
MIRA relies heavily on the PyQt Signal/Slot mechanism. For example, when the CameraThread captures a new frame, it emits a signal that the DetectionEngine receives to perform analysis, which then signals the MainWindow to update the display. This decoupled design makes the code easier to maintain and extend.