This project detects vehicles and license plates from traffic videos using YOLOv5 and EasyOCR, identifies the plate color, and simulates smart traffic signals. Detection data is stored in a CSV file and frames are saved locally.
visionflow/
│
├── visionflow.py # Main application file
├── ViewCSV.py # Optional CSV viewer (not used in this README)
├── traffic_video2.mp4 # Sample traffic video input
├── yolov5su.pt # YOLOv5 model weights (custom/small)
├── frames/ # Saved image frames with detections
├── TrafficRecords.csv # Output file with detection logs
├── requirements.txt # Required Python dependencies
git clone https://github.com/your-username/visionflow.git
cd visionflowpython -m venv venv
venv\Scripts\activate # On Windows
source venv/bin/activate # On macOS/LinuxMake sure to have Python 3.8 or above.
pip install -r requirements.txt
pip install ultralytics, easyocr- ✅ Ensure that the video is added in the import placeholder for the program.
- ✅ Place your YOLOv5 model file (
yolov5su.pt) in the same directory. - 🚫 No need to create
frames/orTrafficRecords.csvmanually; they will be auto-created.
python visionflow.pyThe program will:
- Process video frames.
- Detect vehicles using YOLO.
- Detect license plate text using EasyOCR.
- Determine plate color (Red, Yellow, White).
- Assign a random lane.
- Save frame and detection data to CSV and local image folder.
- Display live traffic signals on video feed.
- TrafficRecords.csv: Contains all detections.
- frames/: Contains saved image frames with annotated plates and vehicle info.
Each row in CSV includes:
- Timestamp
- License Plate Text
- Plate Color
- Lane
- Vehicle Type
- Confidence
- Path to Saved Frame Image
opencv-python
numpy
easyocr
ultralytics- You must have a GPU for optimal performance (for real-time YOLO + OCR) or you can use online freely available compilers.
- If running on Google Colab, replace
cv2.imshowwithcv2_imshow(already done in code). yolov5su.ptis a lightweight YOLO model; you can use your custom-trained one.
You can check the saved frame images in the frames/ directory after running.