A library by Alessio Anzivino, Matteo Spampani for the programming environment Processing. Last update, 19/02/2010.

Histogram of Oriented Gradients (HOG) [1] is a popular method for object detection, particularly suitable for pedestrians detection.
The method is based on the evaluation of histograms calculated on the basis of the orientation of the gradients of the input image. The idea is that the edges and the shapes of objects can be well characterized by the intensity of individual local gradients. Computation of each histogram is obtained by dividing the image into a grid of cells and for each of them is computed a histogram of gradients. Then the cells are grouped into regions called blocks. In addition, to release the response by the terms of brightness, can be useful normalize individual blocks.

From information of the individual blocks you get a descriptor that will be used for detection. The above operations are performed on windows of finite size that analyze the image at multiple scales. For each window is then obtained a descriptor that is then given to a linear SVM classifier that provides predictions about the presence or absence of a pedestrian.

Being the construction procedures of individual descriptors independent of each other, you can run them simultaneously with a multi-threading system. In this way you get a significant performance improvement.

The robustness of the algorithm used (SVM algorithm) and accurate image scanning at multiple scales, often produce a dense group of detection windows for each object, then a merger is required (mean-shift) that brings up to a final identification window.

[1] Navneet Dalal and Bill Triggs. Histograms of oriented gradients for human detection. In Cordelia Schmid, Stefano Soatto, and Carlo Tomasi, editors, International Conference on Computer Vision and Pattern Recognition, volume 2, pages 886-893, INRIA Rhone-Alpes, ZIRST-655, av. de l'Europe, Montbonnot-38334, June 2005.

Keywords Hog, Processing, Pedestrian detection, Human detection, Library

Source. The source code of Hog-Processing is available at GoogleCode, and its repository can be browsed here.


Platform Windows XP, Mac OSX 10.6, Linux
Processing 1.0.5
Dependencies no dependences


Download Hog-Processing version 0.1 in .zip format.


Create a new Processing sketch and from the "Sketch" menu select "Add File", then select "HOG.jar". To use HOG-Processing you have to insert the directive "import hog.*;"


Find a list of examples in the current .zip distribution of Hog-Processing, or have a look at them by following the links below.

Stand-alone application

below you can see in evidence the lines of code you will need to use the whole library:


This work has been carried out as a project for the Multimedia Programming and Design course held by Professor Alberto Del Bimbo [link] within the Computer Engineering program of the University of Florence. The work has been supervised by Walter Nunziati [link] and Lorenzo Seidenari [link], both affiliated with the Multimedia Integration and Communication Center (MICC) laboratory [link].

by Alessio Anzivino and Matteo Spampani, 2010.