This project implements a comprehensive computer vision system for real-time traffic sign recognition while ensuring privacy protection through automatic blurring of vehicle plates and individuals. Designed for autonomous vehicle applications, the system employs multiple YOLO models to detect traffic signs, identify vehicles, and maintain privacy in video surveillance scenarios.
The project addresses the growing need for intelligent transportation systems that balance functionality with privacy protection. By combining traffic sign recognition with GDPR-compliant privacy features, the system provides a complete solution for autonomous vehicles and smart city applications. The implementation demonstrates practical applications of multi-model computer vision pipelines for real-world traffic monitoring scenarios.
The system employs a sophisticated multi-model architecture using three specialized YOLOv11 models, each optimized for specific detection tasks. This modular approach ensures high accuracy across all functions while maintaining real-time performance.
The traffic monitoring pipeline consists of multiple processing stages:
The implementation leverages Ultralytics YOLOv11 framework for all detection tasks. Each model operates independently but sequentially in the pipeline, allowing for modular updates and improvements. The traffic sign model uses high confidence thresholds (0.8) to ensure safety-critical accuracy, while vehicle plate and person detection use moderate thresholds (0.55) for comprehensive privacy protection.
Processing Flow:
Video Frame โ Traffic Sign Detection โ Vehicle Detection โ Plate Detection โ Person Detection โ Blur Application โ Annotation โ Output
Detection confidence thresholds are carefully tuned:
The system implements a two-stage privacy protection mechanism:
Stage 1 - Person Detection:
Stage 2 - Vehicle Plate Detection:
This approach ensures privacy compliance while maintaining traffic sign visibility for analysis.
YOLOv11 processes images through a single neural network, dividing the input into an \(S \times S\) grid. For each grid cell, the model predicts bounding boxes and class probabilities:
Bounding Box Prediction:
$$\mathbf{B} = [x, y, w, h, c]$$
where:
Class Prediction:
$$P(C_i|\text{Object}) = \text{softmax}(\mathbf{z}_i)$$
where \(\mathbf{z}_i\) are the logits for class \(i\).
Final Detection Score:
$$\text{Score}_{i,j} = P(\text{Object}) \times P(C_j|\text{Object})$$
Detections with \(\text{Score}_{i,j} < \tau\) (threshold) are filtered out:
To eliminate duplicate detections, NMS is applied based on Intersection over Union (IoU):
IoU Calculation:
$$\text{IoU}(B_1, B_2) = \frac{\text{Area}(B_1 \cap B_2)}{\text{Area}(B_1 \cup B_2)}$$
NMS Algorithm:
Privacy protection is achieved through Gaussian blur, a convolution operation with a Gaussian kernel:
2D Gaussian Function:
$$G(x, y) = \frac{1}{2\pi\sigma^2} e^{-\frac{x^2 + y^2}{2\sigma^2}}$$
where \(\sigma\) is the standard deviation controlling blur strength.
Convolution Operation:
$$I'(x, y) = \sum_{i=-k}^{k} \sum_{j=-k}^{k} I(x+i, y+j) \cdot G(i, j)$$
where:
Person Blur Parameters:
Vehicle Plate Blur Parameters:
The YOLOv11 models were trained using a composite loss function:
Total Loss:
$$\mathcal{L}_{\text{total}} = \lambda_{\text{box}} \mathcal{L}_{\text{box}} + \lambda_{\text{cls}} \mathcal{L}_{\text{cls}} + \lambda_{\text{obj}} \mathcal{L}_{\text{obj}}$$
Box Regression Loss (CIoU):
$$\mathcal{L}_{\text{box}} = 1 - \text{CIoU} + \frac{\rho^2(\mathbf{b}, \mathbf{b}^{gt})}{c^2} + \alpha v$$
where:
Classification Loss (Binary Cross-Entropy):
$$\mathcal{L}_{\text{cls}} = -\sum_{i=1}^{C} \left[ y_i \log(\hat{p}_i) + (1-y_i)\log(1-\hat{p}_i) \right]$$
where:
Objectness Loss:
$$\mathcal{L}_{\text{obj}} = -\sum_{i=1}^{N} \left[ \mathbb{1}_i^{\text{obj}} \log(\hat{c}_i) + (1-\mathbb{1}_i^{\text{obj}})\log(1-\hat{c}_i) \right]$$
where:
Precision: Accuracy of positive predictions
$$\text{Precision} = \frac{TP}{TP + FP}$$
Recall: Ability to find all positive instances
$$\text{Recall} = \frac{TP}{TP + FN}$$
F1 Score: Harmonic mean of precision and recall
$$F_1 = 2 \times \frac{\text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}}$$
Mean Average Precision (mAP):
$$\text{mAP} = \frac{1}{C} \sum_{i=1}^{C} \text{AP}_i$$
where \(\text{AP}_i\) is the Average Precision for class \(i\), calculated as the area under the Precision-Recall curve.
Bounding Box Center Calculation:
$$x_{\text{center}} = \frac{x_1 + x_2}{2}, \quad y_{\text{center}} = \frac{y_1 + y_2}{2}$$
where \((x_1, y_1)\) and \((x_2, y_2)\) are the top-left and bottom-right corners.
Text Centering (Traffic Sign Labels):
$$x_{\text{text}} = x_1 + \frac{(x_2 - x_1) - w_{\text{text}}}{2}$$
$$y_{\text{text}} = y_1 - 10$$
where \(w_{\text{text}}\) is the width of the label text.
opencv-python>=4.5.0
numpy>=1.21.0
ultralytics>=8.0.0
# Clone the repository
git clone https://github.com/kemalkilicaslan/Traffic-Signs-Recognition-Vehicle-Plate-and-Person-Blurring-System.git
cd Traffic-Signs-Recognition-Vehicle-Plate-and-Person-Blurring-System
# Install required packages
pip install -r requirements.txt
Traffic-Signs-Recognition-Vehicle-Plate-and-Person-Blurring-System/
โโโ Traffic-Signs-Recognition-Vehicle-Plate-and-Person-Blurring-System.py
โโโ README.md
โโโ requirements.txt
โโโ LICENSE
Download and place these model files in the project directory:
python Traffic-Signs-Recognition-Vehicle-Plate-and-Person-Blurring-System.py
Update the video filename in the script:
video = 'Traffic.mp4' # Change to your video file
Modify confidence thresholds based on your requirements:
# In the script, modify these parameters:
# Traffic sign detection (high precision for safety)
traffic_signs_results = traffic_signs_detection_model(frame, conf=0.8)
# Person detection (comprehensive privacy)
yolov11_results = YOLO_model(frame, conf=0.55)
# Vehicle plate detection (within vehicle regions)
plate_results_in_vehicle = vehicle_plate_detection_model(vehicle_region, conf=0.55)
Adjust Gaussian blur parameters for different privacy requirements:
# Person blurring (moderate anonymization)
blurred_person = cv2.GaussianBlur(person_region, (99, 99), 30)
# Vehicle plate blurring (extreme unreadability)
blurred_plate = cv2.GaussianBlur(plate_region, (255, 255), 30)
# Custom blur settings:
# - Kernel size must be odd numbers (e.g., 51, 99, 151, 255)
# - Larger kernels = stronger blur
# - Sigma (last parameter) controls blur spread
The processed video is saved as:
Traffic-Signs-Recognition-Vehicle-Plate-and-Person-Blurring.mp4
Training Configuration:
Performance Metrics:
| Metric | Value |
|---|---|
| Precision | 95.2% |
| Recall | 92.8% |
| F1 Score | 0.940 |
| mAP@0.5 | 96.1% |
| mAP@0.5:0.95 | 78.4% |
Training Results Analysis:
The training curves show:
Training Configuration:
Performance Metrics:
| Metric | Value |
|---|---|
| Precision | 93.7% |
| Recall | 89.4% |
| F1 Score | 0.915 |
| mAP@0.5 | 94.8% |
| mAP@0.5:0.95 | 81.2% |
Training Results Analysis:
The training curves demonstrate:
Traffic Sign Recognition:
Privacy Protection:
| Component | Processing Time (ms/frame) | Accuracy |
|---|---|---|
| Traffic Sign Detection | 15-20 ms | 94.8% mAP |
| Vehicle Detection | 12-18 ms | ~95% (COCO) |
| Plate Detection | 8-12 ms | 96.1% mAP |
| Person Detection | 10-15 ms | ~90% (COCO) |
| Blur Application | 5-10 ms | 100% coverage |
| Total Pipeline | 50-75 ms | ~13-20 FPS |
The system recognizes 24 traffic signs organized by category:
โโโโโโโโโโโโโโโโโ
โ Input Frame โ
โโโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ TRAFFIC SIGN DETECTION (Stage 1) โ
โ Model: Traffic-Signs-Recognition.pt (Confidence: 0.8) โ
โ Output: 24-class classification with bounding boxes โ
โ Action: Draw centered labels with white background โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ VEHICLE & PERSON DETECTION (Stage 2) โ
โ Model: yolo11l.pt (Confidence: 0.55) โ
โ Classes: Person, Car, Motorcycle, Bus, Truck โ
โ Output: Bounding boxes for contextual detection โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PRIVACY PROTECTION (Stage 3) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ PERSON BLURRING โ โ
โ โ โข Full-body region extraction โ โ
โ โ โข Gaussian blur: kernel (99ร99), sigma=30 โ โ
โ โ โข Replace original region with blurred version โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ VEHICLE PLATE BLURRING โ โ
โ โ โข Crop vehicle region from frame โ โ
โ โ โข Detect plates within vehicle region (conf: 0.55) โ โ
โ โ โข Gaussian blur: kernel (255ร255), sigma=30 โ โ
โ โ โข Replace plate region with extreme blur โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ VISUALIZATION & OUTPUT โ
โ โข Display annotated frame with cv2.imshow() โ
โ โข Write frame to output video file โ
โ โข Check for 'q' key press to exit โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโ
โ Output Frame โ
โโโโโโโโโโโโโโโโโ
Frame N
โ
โโโโบ [Traffic Sign Detection] โโโบ 24 classes @ 80% confidence
โ โ
โ โโโโบ Label overlay (centered, white bg)
โ
โโโโบ [YOLO Detection] โโโบ Person, Car, Motorcycle, Bus, Truck
โ โ
โ โโโโบ [Person] โโโบ Extract region โโโบ Blur (99ร99) โโโบ Replace
โ โ
โ โโโโบ [Vehicle] โโโบ Crop region โโโบ [Plate Detection @ 55%]
โ โ
โ โโโโบ Blur (255ร255) โโโบ Replace
โ
โโโโบ [Output Writer] โโโบ Save frame
Frame N+1
...
FOR each video frame:
# Stage 1: Traffic Sign Recognition
traffic_signs = traffic_signs_model.detect(frame, conf=0.8)
FOR each sign in traffic_signs:
draw_bounding_box(frame, sign.box)
label = f"{sign.class_name} {sign.confidence:.2f}"
draw_centered_label(frame, sign.box, label)
# Stage 2: Vehicle & Person Detection
detections = yolo11l_model.detect(frame, conf=0.55)
FOR each detection in detections:
IF detection.class == 'person':
# Privacy: Blur entire person
person_region = extract_region(frame, detection.box)
blurred_person = gaussian_blur(person_region, kernel=99, sigma=30)
replace_region(frame, detection.box, blurred_person)
ELIF detection.class IN ['car', 'motorcycle', 'bus', 'truck']:
# Contextual plate detection
vehicle_region = extract_region(frame, detection.box)
plates = plate_model.detect(vehicle_region, conf=0.55)
FOR each plate in plates:
# Adjust coordinates to original frame
plate_box_global = adjust_to_frame_coordinates(plate.box, detection.box)
# Privacy: Blur plate beyond recognition
plate_region = extract_region(frame, plate_box_global)
blurred_plate = gaussian_blur(plate_region, kernel=255, sigma=30)
replace_region(frame, plate_box_global, blurred_plate)
# Stage 3: Output
display(frame)
write_to_video(frame)
IF key_pressed == 'q':
BREAK
| Library | Version | Purpose |
|---|---|---|
| opencv-python | 4.5+ | Video processing, frame manipulation, blur operations |
| ultralytics | 8.0+ | YOLO model inference and detection |
| numpy | 1.21+ | Array operations and coordinate calculations |
Backbone:
Neck:
Head:
Model Statistics:
Traffic Signs Recognition Model:
Vehicle Plate Detection Model:
General Object Detection Model:
The system implements multiple privacy protection measures:
Personal Data Protection:
Data Minimization:
Privacy by Design:
GDPR Article 25 Compliance:
This project is open source and available under the Apache License 2.0.
Special thanks to the Ultralytics team for developing and maintaining the YOLOv11 framework. This project benefits from the OpenCV community's excellent computer vision tools. The custom models were trained using publicly available traffic sign and vehicle plate datasets for educational and research purposes. Privacy protection features are designed with GDPR compliance principles in mind.
Note: Ensure you have proper permissions and comply with privacy regulations when using vehicle plate detection and person recognition technology. This system is designed with GDPR compliance in mind and includes automated privacy protections. This project is intended for educational and research purposes in autonomous vehicle development and privacy-compliant surveillance systems. Always verify compliance with local data protection laws before deploying in production environments.