/License-and-speed-Detection

This repository focuses on evaluating real-time traffic videos and identifying license plate numbers and matching vehicle speeds.

Primary LanguagePython

ABOUT THE REPOSITORY

This repository focuses on evaluating real-time traffic videos and identifying license plate numbers and matching vehicle speeds. For the project:

  1. Software used: Spyder
  2. Methodology: YOLOv5 and DeepSort(for vehicle tracking)
  3. License Image Dataset: kaagle.com
  4. UI software: streamlit

OBJECTIVE

The objective of the project is to create a UI that will display the speed and number plate of a vehicle.

  1. Type of vehicle: For a given input video data, classify the vehicle as car,truck,bus etc
  2. Number Plate Detection: To draw a rectangle around the number plate of the vehicle and also display the number
  3. Speed Detection: To detect the speed of the vehicle.
  4. Generate an Excel: The excel should will record all the obervation.

PLAN OF ATTACK

image

METHODOLOGY DESCRIPTION

  1. Optical character recognition is a technology that recognizes text within a digital image. It is commonly used to recognize text in scanned documents and images. OCR software can be used to convert a physical paper document, or an image into an accessible electronic version with text. A Python library called EasyOCR makes it possible to turn images into text. It has access to over 70 languages, including English, Chinese, Japanese, Korean, Hindi, and many more are being added. It is by far the simplest approach to implement OCR.
!pip install easyocr
import easyocr
  1. YOLO an acronym for 'You only look once', is an object detection algorithm that divides images into a grid system. Each cell in the grid is responsible for detecting objects within itself. After the release of YOLOv4 Glenn Jocher introduced YOLOv5 using the Pytorch framework. YOLOv5 is one of the most famous object detection algorithms due to its speed and accuracy.
git clone https://github.com/ultralytics/yolov5  # clone
cd yolov5
pip install -r requirements.txt  # install
import torch
  1. Performance is frequently improved by pre-training a model on a very large dataset to acquire useful representations, and then fine-tuning it on the relevant task. This is done using Transfer learning

  2. The computer vision research community frequently uses the benchmarking dataset Common Objects in Context (COCO). Even general practitioners working in the field can use it. COCO contains over 330,000 images, of which more than 200,000 are labelled, across dozens of categories of objects. The COCO dataset is designed to represent a vast array of things that we regularly encounter in everyday life, from vehicles like bikes to animals like dogs to people.

label_names = {2: 'car', 5: 'bus', 7: 'truck'}
  1. Object tracking is an important task in computer vision. Object trackers are an integral part of many computer vision applications that process the video stream of cameras. SORT stands for Simple Online Real-time Tracking. The simple Sort Algorithm uses bounding box prediction, Kalman filter and IoU matching.
    • Bounding box prediction, The first step is detect where are the images present in the image. This can be accomplished using any CNN architecture, YOLO,R-CNN etc.
    • Kalman filter is a linear approximation. It predicts what is the future location of the dected object. Uses of these future predictions are:
      • Predict whether the object that we were tracking was the same object or not.
      • Deal with the problem of occlusion
    • IoU stands for intersection over union. It determines how much the two bounding boxes are similar to each other. In our project we have n number of vehicles and we are detecting in a particlar frame. We also have n IDs that we need to assign to these particular vehicles. IDs are important to determine which object we are tracking. So we need to assign n detection to n IDs. For each ID we have the IoU score corresponding to each detection

RESULT

Tested my model on real-time traffic videos and recognised numbers from detected number plates. Further I also estimated vehicles speed using distance-time formulae and also classified the vehcile type.

Untitled.mp4

The report generated:

image

REFERENCE

  1. https://github.com/ultralytics/yolov5
  2. https://learnopencv.com/edge-detection-using-opencv/
  3. https://www.geeksforgeeks.org/python-bilateral-filtering/
  4. https://docs.opencv.org/4.x/da/d22/tutorial_py_canny.html
  5. https://docs.opencv.org/4.x/dc/da5/tutorial_py_drawing_functions.html
  6. https://www.oreilly.com/library/view/mastering-opencv-4/9781789344912/16b55e96-1027-4765-85d8-ced8fa071473.xhtml
  7. https://www.geeksforgeeks.org/python-opencv-cv2-puttext-method/
  8. https://pyimagesearch.com/2020/09/14/getting-started-with-easyocr-for-optical-character-recognition/
  9. https://docs.opencv.org/4.x/dc/da5/tutorial_py_drawing_functions.html
  10. https://cocodataset.org/#home