Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV Python and Histogram of Oriented Gradient

Is there any useful documentation for using the HOGDescriptor functionality in Python OpenCV? I have read the C++ documentation, but the Python version functions differently and I cannot figure it out just by tinkering.

Most specifically, I am seeking an OpenCV command in Python that takes an image and a pixel location as input (and possibly also some parameters about the size of a detection window) and then just returns a Python array that contains the HOG feature vector (i.e. a list or NumPy array, etc., where the jth element of the list is the jth histogram component from a histogram of oriented gradients).

My goal is to feed these histograms into the scikits.learn SVM pipelines (so I can avoid the OpenCV SVM training), but to do this I need the actual feature vectors themselves and not the sort of HOG processing chain pipelines stuff that OpenCV appears to use.

Any other Python implementations of HOG code would work too. I need something reasonably efficient though to compare with another code base that I am writing myself.

like image 660
ely Avatar asked Oct 04 '11 00:10

ely


People also ask

What is Histogram of Oriented Gradients used for?

The histogram of oriented gradients (HOG) is a feature descriptor used in computer vision and image processing for the purpose of object detection. The technique counts occurrences of gradient orientation in localized portions of an image.

How does HOG algorithm work?

HOG decomposes an image into small squared cells, computes an histogram of oriented gradients in each cell, normalizes the result using a block-wise pattern, and return a descriptor for each cell.


1 Answers

This is a little late, but, for future reference, scikit-image has an implementation of HOG. This is a single function that could extract the Histogram of Oriented Gradients for a given image.

like image 116
Tony S Yu Avatar answered Sep 24 '22 04:09

Tony S Yu