Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HOG for "detecting object" opencv

I would like to know, if there is any code or any good documentation available for implementing HOG features? I tried to read the documentation here but it's quite difficult to understand and it needs SVM..

What I need is just to implement a HOG detector for objects.... Like what it does SIFT or SURF

Btw, I'm not interesting in this work.

Thank you..

like image 787
Mario Avatar asked Oct 04 '11 00:10

Mario


People also ask

Can OpenCV be used for object detection?

OpenCV has a bunch of pre-trained classifiers that can be used to identify objects such as trees, number plates, faces, eyes, etc. We can use any of these classifiers to detect the object as per our need.

How does object detection work in OpenCV?

Basically, the Haar cascade technique is an approach based on machine learning where we use a lot of positive and negative images to train the classifier to classify between the images. Haar cascade classifiers are considered as the effective way to do object detection with the OpenCV library.

What is hog feature extraction?

HOG, or Histogram of Oriented Gradients, is a feature descriptor that is often used to extract features from image data. It is widely used in computer vision tasks for object detection.

How do you get hog features in Python?

Python Code The hog() function takes 6 parameters as input: image : The target image you want to apply HOG feature extraction. orientations : Number of bins in the histogram we want to create, the original research paper used 9 bins so we will pass 9 as orientations.


2 Answers

you can take a look at http://szproxy.blogspot.com/2010/12/testtest.html

he also published "tutorial" for HOG on source forge here: http://sourceforge.net/projects/hogtrainingtuto/?_test=beta

I know this since I'm having the same problem as you. The tutorial though isn't what i would call a tutorial, its a bunch of source codes, no documentation, but I assume that it works and can at least get you somewhere.

like image 156
mugetsu Avatar answered Oct 04 '22 16:10

mugetsu


At the end and simplifying a bit, all that you need to detect specific objects in image is:

  • Localize "points of interest" to extract the patches:

In order to get points of interest, you can use some algorithms like Harris corner detector, randomly or something simply like sliding windows.

  • From these points get patches:

You will have to take the decission of the patch size.

  • From these patches compute the feature descriptor. (like HOG).

Instead of HOG you can use another feature descriptor like SIFT, SURF...
HOG's implementation is not too hard. You have to calculate the gradients of the extracted patch doing applying Sobel X and Y kernels, after that you have to divide the patch in NxM cells, 8x8 for instance, and compute an histogram of gradients, angle and magnitude. In the following link you can see it more detailed explanation: HOG Person Detector Tutorial

  • Check your feature vector in the previously trained classifier

Once you got this vector, check if it is the desired object or not with a previously trained classifier like SMV. Instead SVM you could use NeuralNetworks for instance.

SVM implementation is more dificult, but there are some libraries like opencv that you can use.

like image 26
omotto Avatar answered Oct 04 '22 15:10

omotto