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 O开发者_开发百科penCV 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.
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.
How about a bit of Matlab as inspiration, belonging to this article
take a look at http://sourceforge.net/projects/hogtrainingtuto/?_test=beta for some HOG python code and a bunch of C, cpp, java implementations. As for real documentations of python and opencv, I too am at a loss. But this should help you a bit
The 'Poselets' implementation here has a C implementation of HOG descriptors which, although written with matlab in mind, can be adapted to run with python using ctypes and numpy.
You can remove all the mex routines, and declare your input and output arrays as float *
in the C function.
You do need to make sure that your numpy arrays are Fortran contiguous. This can be achieved by:
image = image.copy(order='F', dtype = float32)
精彩评论