⚠️ Status: Under Construction / RefactoringThis project is currently undergoing a major refactoring and optimization process. The codebase is being updated to improve detection accuracy and robustness, particularly for double-row license plates.
This project aims to implement a robust license plate recognition system. The current focus is on the Plate Localization module, which has been significantly enhanced to handle various lighting conditions and plate types.
The plate localization algorithm has been redesigned with the following pipeline:
- Center Crop: The image is cropped to focus on the central region, reducing processing time and background noise.
- Dual-Direction Sobel Edge Detection:
- Combines Sobel X (vertical edges) and Sobel Y (horizontal edges) with equal weights.
- This ensures that both the vertical strokes of digits/letters and the horizontal strokes of Chinese characters are captured.
- Pre-Dilation:
- Applies a small (3x3) dilation to the binary edge image.
- This strengthens weak edges, ensuring they survive the subsequent morphological operations.
- Morphological Closing:
- Uses a small (3x3) kernel to connect broken plate borders.
- Avoids using large kernels that might merge the plate with surrounding background clutter.
- Contour Analysis (RETR_TREE):
- Extracts contours using the
RETR_TREEmode to detect nested structures. - Leverages the hierarchy to find "parent" contours (plate borders) that contain "child" contours (characters).
- Extracts contours using the
- Candidate Scoring:
- Candidates are scored based on Aspect Ratio (AR) and Distance from Center.
- High Weight on AR: The system strongly prioritizes candidates with an AR close to 1.98 (standard for double-row plates).
- Projection Refinement:
- The detected region undergoes a projection analysis (horizontal and vertical) to precisely crop the plate boundaries, removing excess padding.
Install the required dependencies:
pip install -r requirements.txtTo verify the plate localization logic:
python 01_Test_locate_plate.py- Refactor Plate Localization (Dual Sobel, AR Scoring)
- Optimize Character Segmentation
- Update Character Recognition Logic
- End-to-end Pipeline Testing
The rest of this documentation is intentionally left blank as the project evolves.