Note: this repository was created for the final project of an undergraduate course and won't receive any major updates. There are methods with better results than HoG for traffic sign detector, such as Deep Learning architectures. Still, you can use this repository as a study reference or for some practical purposes.
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.
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 .)
- Compile
imglab
:
cd dlib/tools/imglab
mkdir build
cd build
cmake ..
cmake --build .
- Create XML from sample images:
dlib/tools/imglab/build/imglab -c images/pare/training.xml images/pare/train/*.(jpg|jpeg|png)
dlib/tools/imglab/build/imglab images/pare/training.xml
dlib/tools/imglab/build/imglab -c images/pare/testing.xml images/pare/test/*.(jpg|jpeg|png)
dlib/tools/imglab/build/imglab images/pare/testing.xml
- Use
shift+click
to draw a box around signs.
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.
To visualize detectors, use the program view_hog
. Usage:
build/view_hog svm_detectors/pare_detector.svm
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
To run the examples:
build/detect examples/video/*
build/detect --wait -u1 examples/images/*