Skip to content

Traffic sign detector and classifier that uses dlib and its implementation of the Felzenszwalb's version of the Histogram of Oriented Gradients (HoG) detector

Notifications You must be signed in to change notification settings

tiagofga/transito-cv

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a traffic sign detector and classifier that uses dlib and its implementation of the Felzenszwalb's version of the Histogram of Oriented Gradients (HoG) detector.

The training examples used in this repository are from Brazilian road signs, but the classifier should work with any traffic signs, as long as you train it properly. Google Street View images can be used to train the detectors. 25~40 images are sufficient to train a good detector.

Note: all programs accept -h as command-line parameter to show a help message.

Build

mkdir build
(cd build; cmake .. && cmake --build .)

If you want to enable AVX instructions (make sure you have compatibility):

(cd build; cmake .. -DUSE_AVX_INSTRUCTIONS=ON && cmake --build .)

Mark signs on images

  1. Compile imglab:
cd imglab
mkdir build
cd build
cmake ..
cmake --build .
  1. Create XML from sample images:
imglab/build/imglab -c images/pare/training.xml images/pare/train/*.(jpg|jpeg|png)
imglab/build/imglab images/pare/training.xml
imglab/build/imglab -c images/pare/testing.xml images/pare/test/*.(jpg|jpeg|png)
imglab/build/imglab images/pare/testing.xml
  1. Use shift+click to draw a box around signs.

Train the fHOG detector

To train a fHOG detector, run build/hog_detector. For example, to run the detector on the image/pare/ folder in the verbose mode, upsampling each image once, with a threshold filter with value 0.4, execute the following command:

build/hog_detector -v -u1 --filter 0.4 images/pare/

The detector will be saved to the file detector.svm. To change the file, use the --detector-name option.

Run build/hog_detector -h for more details.

Visualize HOG detectors

To visualize detectors, use the program view_hog. Usage:

build/view_hog svm_detectors/pare_detector.svm

image

Detect and Classify

To detect and classify frames of a video, run detect with the video frames as parameters:

build/detect examples/video/*.png

If your images are not in sequence (i.e. frames of a video), use the parameter --wait to wait for user input to show next image.

build/detect --wait examples/images/*.jpg

Examples

To run the examples:

build/detect examples/video/*
build/detect --wait -u1 examples/images/*

image6 image7 image8

About

Traffic sign detector and classifier that uses dlib and its implementation of the Felzenszwalb's version of the Histogram of Oriented Gradients (HoG) detector

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 99.4%
  • Other 0.6%