Traffic signs detection and classification in real time

A new version using SSD will be released this summer for anyone need higher accuracy detection method. Stay tuned for new update!

1. Description

This project is a traffic signs detection and classification system on videos using OpenCV. The detection phase uses Image Processing techniques that create contours on each video frame and find all ellipses or circles among those contours. They are marked as candidates for traffic signs.

Detection strategy:

  1. Increase the contrast and dynamic range of the video frame
  2. Remove unnecessary colors like green with HSV Color range
  3. Use Laplacian of Gaussian to display border of objects
  4. Make contours by Binarization.
  5. Detect ellipse-like and circle-like contours

In the next phase - classification phase, a list of images are created by cropping from the original frame based on candidates' coordinate. A pre-trained SVM model will classify these images to find out which type of traffic sign they are.

Currently supported traffic signs (The name of each sign's file is corresponding to their class in SVM): Note:

The SVM Model is trained each time the main.py called, before the detection phase but I still save the model in data_svm.dat to implement the model-reload function in the future to avoid retraining phase.

If a traffic sign is detected, it will be tracked until it disappears or there is another bigger sign in the frame. The tracking method is Dense Optical Flow.

2. Prerequisites:

3. System structure

a. There are 3 python files as 3 modules:

Other files:

b. Dataset

The Dataset folder contains images for training SVM models. There are 12 folders contains cropped images of traffic signs. Each folder is named as the class of the traffic signs it contains. The special 0 folder contains non-traffic-sign cropped images which can be recognized as traffic signs in the detection phase. Wrong detected traffic signs

The dataset is created by applying the detection phase on many videos with various parameters to mark all traffic signs and then manually separating them into their right classes.

Each time run the program, the dataset can be updated by checking all generated cropped images of detected traffic signs, then find all misclassified traffic signs.

4. Installation

There are two ways of running the program:

Use default arguments:

$python3 main.py

Use custom arguments:

$python3 main.py
optional arguments:
  -h, --help            show this help message and exit
  --file_name FILE_NAME
                        Video to be analyzed
  --min_size_components MIN_SIZE_COMPONENTS
                        Min size component to be reserved
  --similitary_contour_with_circle SIMILITARY_CONTOUR_WITH_CIRCLE
                        Similarly to a circle

5. Result

6. Disadvantages

MIT License © 2018 Hoàng Lê Hải Thanh (Thanh Hoang Le Hai) aka GhostBB