The main objective of this project is to identify overspeed vehicles, using Deep Learning and Machine Learning Algorithms. After acquisition of series of images from the video, trucks are detected using Haar Cascade Classifier. The model for the classifier is trained using lots of positive and negative images to make an XML file. This is followed by tracking down the vehicles and estimating their speeds with the help of their respective locations, ppm (pixels per meter) and fps (frames per second). Now, the cropped images of the identified trucks are sent for License Plate detection. The CCA (Connected Component Analysis) assists in Number Plate detection and Characters Segmentation. The SVC model is trained using characters images (20X20) and to increase the accuracy, 4 cross fold validation (Machine Learning) is also done. This model aids in recognizing the segmented characters. After recognition, the calculated speed of the trucks is fed into an excel sheet along with their license plate numbers. These trucks are also assigned some IDs to generate a systematized database.
To run SpeedDetection&_License_Plate_Detection.py, follow these steps below:
Methodology:
Image Acquisition: Extracting series of images from a video one by one, then reading them using cv2 (Open Source Computer Vision) library.
Trucks Detection: Using Haar Cascade CLassifier This Algorithm includes 4 stages: a. Haar Feature Selction b. Creating Integral Images c. Adaboost (Adaptive boosting) Training d. Cascading Classifiers Functions Used: CascadeClassifier and detectMultiScale
Training a machine to make an XML file(): I WAY: Command Prompt Method a. Collection of Image Database b. Augmentation: for boosting image database c. Crop and mark positive images using Objectmarker or Image Clipper d. Haar Training Refernce: 'www.cs.auckland.ac.nz/~m.rezaei/Downloads.html' II WAY: Cascade Trainer (Graphical User Interface) Install GUI software and specify the values of parameters. Reference: 'http://amin-ahmadi.com/cascade-trainer-gui/'
Tracking the detected trucks using dlib library: Functions Used: a. dlib.correlation_tracker() b. dlib.correlation_tracker().start_track() c. dlib.rectangle
Speed Estimation: Speed (in km/hr) = Distance Travelled by the detected trucks (in meters) fps 3.6
CCA (Connected Component Analysis): for detecting License Plate and segmenting Characters Functions Used: skimage.measure.label and skimage.measure.regionprops
Assumptions used in this code: (change it accordingly) height of the license plate = 6% - 18% of the height of the cropped truck image width of the license plate = 8.5% - 20% of the width of the cropped truck image height of the characters to be segmented = 18.75% - 37.5% of the height of the license plate width of the characters to be segmented = 5% - 40% of the width of the license plate
Support Vector Classifier and Cross Validation (4-fold): for predicting Characters
Working with Excel Sheet: Using 'openpyxl' library, the calculated speed of trucks can be fed into the excel sheet along with their license plate numbers. These trucks are assigned some IDs to generate a systemized database.
Overspeed Vehicle Enumeration
Limitations:
Old trucks cannot be identified because the machine is trained using only new models of trucks.
Inspired by https://github.com/apoorva-dave/LicensePlateDetector/blob/master/DetectPlate.py Reference: https://github.com/kraten/vehicle-speed-check https://github.com/kraten/vehicle-speed-check/blob/master/myhaar.xml