5
votes

I would like to know, if there is any implementation for HOG descriptor for objects like "cars" and NOT for Human in MATLAB?

But in case, there is only for Human, can you guide me to that code, and give me so HINTS in order to improve the code to be used for "objects such as cars or motorcycles"

4
Hi, i would like to suggest that you first try to google.. Anyway here is a link for matlab code you give an image as input (not only humans any image it will produce a hog feature vector of length 81) HOGG453
@Sistu this code without any description plus it is used for human detection :(Mario
Take a gander at the paper that the description links to. Or at least an excerpt from the IEEE proceedings. My (very general) understanding is that this function is designed to return HOG descriptors for the provided image. You can then use those descriptors for your application. So if you feed it a "car" you'll get descriptors you can use for "cars".Ben A.
Thank you for your replies guys, I would like to know exactly, why the feature vector is 81*1? second of all, I want to know, if its correct like this, so to make a classifier, I have to collect descriptor of one object as positive against false samples, so I have to collect the descriptors for the object "car" and train it against something else, which I have to get descriptors of 100 images of "cars" and 100 for another object as negative samples, Am I correct? Finally, I want one of you to put an answer to accept, so others can see the solution and know that it is accepted. Thank youMario
This website might help you: geocities.ws/talh_davidcSomethingSomething

4 Answers

2
votes

There is now a function extractHOGFeatures in the Computer Vision System Toolbox.

1
votes

HOG is a kind of feature descriptor and it can be applied to whatever object you want. The implementation would be no change except for parameters of block size, cell size, block stride, etc. To get a descriptor for cars, you need to provide positive and negative samples of them. Opencv provides the function for users to train the classifier. It should be same for matlab if it provides the code to train the classifier.

1
votes

Well you can Use VLFeat Toolbox, Its has very effiecient implimentaion of HOG, u can find hOG feature of any object, also u can visualize. If "im.jpg" if your input image, You can get HOG feature using hog = vl_hog("im.jpg",8,'verbose') Here 8 is ur window size, you can adjust accordingly.

For displaying the feature imhog = vl_hog('render',hog,'verbose')

0
votes

Here is an excellent Matlab code that fully implements Dalal's algorithm. I have tested and used this code for many major academic projects.

http://hi.baidu.com/fpmaldfoamdfmze/item/4f3b3ac881affcb00c0a7b11 All credit goes to the person who posted this!

HOG is not specific to pedestrian detection. You can use it with any rigid (or apploximately rigid) object.

To use this code, you need to understand how HOG is calculated over a region. The region is divided into overlapping 'blocks'. Blocks consist of a number of 'cells'. A spatial orientation histogram is computed in each block. The final vector is formed by concatenating these spatial histograms. The parameters that you can tweak are

cellpw, cellph: cell's pixel width and height respectively.

nblockw, nblockh: block size counted by cells number in x and y directions respectively.

nthet: Number of angle bins.

issigned: whether signed or unsigned gradient is taken

overlap: amount of overlap between blocks specified as a fraction

isglobalinterpolate: whether global or local interpolation of 3d histogram

normmethod: type of norm used

You can fist try with the default parameters -

cellpw = 8; cellph = 8; nblockw = 2; nblockh = 2; nthet = 9; overlap = 0.5; isglobalinterpolate = 'localinterpolate'; issigned = 'unsigned'; normmethod = 'l2hys';

In matlab getting the feature is something like

I = imread('car.png');
Ig = rgb2gray(I);
F = hogcalculator(Ig, 8, 8, 2, 2, 9, 0.5,'localinterpolate', 'unsigned', 'l2hys');

The dimension/length of F depends on the paramenters you choose.

Answering your comment, Yes, you have to build these features for your positive(car) and negative(non-car) images to build a detection system. SVM is typically used as classifier. I suggest using libsvm library -

http://www.csie.ntu.edu.tw/~cjlin/libsvm/

Once you build your training set, train with your training set. Tweak SVM parameters to get the highest accuracy. The parameters given in the example may not be the best, you can always try a different set. I would try changing nthet, cellpw and cellph first. Good luck!