Object Detection Framework using HOG as descriptor and Linear SVM as classifier.
Python
Latest commit 872d519 Jul 23, 2015 @bikz05 Update README.md
Permalink
Failed to load latest commit information.
bin 1st alpha version released Jun 13, 2015
data Configuration file loaded Jun 19, 2015
object-detector Configuration file loaded Jun 19, 2015
.gitignore 1st alpha version released Jun 13, 2015
LICENSE Initial commit Jun 5, 2015
README.md Update README.md Jul 23, 2015

README.md

object-detector

Object Detector using HOG as descriptor and Linear SVM as classifier. | Video

Run the code

I have created a single python script that can be used to test the code. To test the code, run the lines below in your terminal.

git clone https://github.com/bikz05/object-detector.git
cd object-detector/bin
test-object-detector

The test-object-detector will download the UIUC Image Database for Car Detection and train a classifier to detect cars in an image. The SVM model files will be stored in data/models, so that they can be resused later on.

Configuration File

All the configurations are in the data/config/config.cfg configuration files. You can change it as per your need. Here is what the default configuration file looks like (which I have set for Car Detector)-

[hog]
min_wdw_sz: [100, 40]
step_size: [10, 10]
orientations: 9
pixels_per_cell: [8, 8]
cells_per_block: [3, 3]
visualize: False
normalize: True

[nms]
threshold: .3

[paths]
pos_feat_ph: ../data/features/pos
neg_feat_ph: ../data/features/neg
model_path: ../data/models/svm.model

About the modules

  • extract-features.py -- This module is used to extract HOG features of the training images.
  • train-classifier.py -- This module is used to train the classifier.
  • nms.py -- This module performs Non Maxima Suppression.
  • test-classifier.py -- This module is used to test the classifier using a test image.
  • config.py -- Imports the configuration variables from config.cfg.

Some of the results

Test Image 1

Detections before NMS

Image 1

Detections after NMS

Test Image 2

Detections before NMS

Detections after NMS

Test Image 3

Detections before NMS

Detections after NMS

Test Image 4

Detections before NMS

Detections after NMS

TODO

Here is list of tasks that I am planning to implement in the future -

  • Optimize code to use more numpy vectorized codes.
  • Faster NMS code.
  • Add bootstrapping (Hard Negative Mining) code.

Useful tutorials

  1. Histogram of Oriented Gradients and Object Detection
  2. Image Pyramids with Python and OpenCV
  3. Sliding Windows for Object Detection with Python and OpenCV
  4. Non-Maximum Suppression for Object Detection in Python
  5. (Faster) Non-Maximum Suppression in Python
  6. Texture Matching using Local Binary Patterns (LBP), OpenCV, scikit-learn and Python
  7. Detección de objetos Course by Coursera