-
Notifications
You must be signed in to change notification settings - Fork 119
home‐yolo.py
Mathew edited this page Feb 20, 2024
·
1 revision
The home-yolo.py
script serves as the central command unit for the Automatic License Plate Recognition (ALPR) system, orchestrating the application's core functionalities, including the user interface (UI) initialization, video processing, plate detection, and interaction with the database for logging and resident management.
- Initializes the PySide6 main window and loads the UI from
mainFinal.ui
. - Configures button actions to start and stop video processing, and to navigate through resident and entry logs.
- Utilizes two background threads (
Worker1
andWorker2
) for handling video capture and processing without blocking the UI. -
Worker1
captures video frames, applies the YOLOv5 model to detect license plates, and crops the detected plates for further processing. - The cropped plates are then passed through another YOLOv5 model to recognize characters on the plates.
- Dynamically updates the main window with detected plates, character recognition results, and database queries regarding resident information and entry logs.
- Implements functionalities for adding new residents, viewing resident details, and logging entry times and plate details.
- Interacts with the application's database to retrieve and update information related to recognized plates and associated residents.
- Utilizes
db_entries_time
,dbGetAllEntries
,db_get_plate_status
, anddb_get_plate_owner_name
for database operations.
- Includes utility functions for device selection based on the availability of CUDA or MPS, ensuring optimal model performance.
- Implements image processing functions such as cropping detected plates and formatting the recognized plate text for standardization and readability.
- Catches and suppresses warnings related to user warnings.
- Manages system resources effectively, including garbage collection and clearing CUDA cache to ensure smooth operation.
-
Initialization: On application launch,
MainWindow
is instantiated, setting up the GUI and connecting actions to their respective slots. -
Video Processing Start: Upon user interaction,
Worker1
starts capturing and processing video frames in a separate thread. - Plate Detection: Frames are processed using a pre-trained YOLOv5 model to detect license plates.
- Character Recognition: Detected plates are further processed to recognize characters using another YOLOv5 model.
- Database Queries: Recognized plate numbers are used to query the database for related resident information and entry logs.
- GUI Updates: The main window is updated in real-time with the processed information for user interaction.
- Resource Management: Ensures efficient use of resources and clean-up on application closure.
home-yolo.py
embodies the core logic and workflow of the ALPR system, integrating deep learning models with a user-friendly interface for real-time license plate recognition and management. Through a combination of PySide6 for the UI, PyTorch for deep learning inference, and efficient resource management, it provides a robust solution for automatic license plate detection and recognition.