# How to match 2 HOG for object detection?

Basically I am implementing a system of object detection. I have already implemenet SIFT and ORB for detection.

Now I would like to add HOG matching. I can extract HOG feature by doing:

Mat image(imread("object.jpg",1));
vector<float> features;
vector<Point> locations;
HOGDescriptor *hog = new HOGDescriptor();
hog->compute(image,featjres,Size(8,8), Size(32,32),locations);


Now I would like to use this information to find a match in a query image containg the object, I don't want to use SVM. Any sample code?

And if the SVM is the only way, how can I train it with my model image? (Sample code if you can thanks)

I wonder why it is not possibile to match it like we were matching SIFT descriptor and then doing a sort of ratio test =/
The SVM classifier needs training and it time consuming

edit retag close merge delete

Sort by » oldest newest most voted

There are a number of fundamental differences between texture descriptors and keypoint descriptors. And those differences make them fit for very different tasks - usually recognition tasks that are performed well by one method fail with the other and vice-versa.

Here are some highlights from the two paradigms:

Texture descriptors

Examples: HOG, LBP, Haar.

How they work: Given a texture area, they uniformly process all of it to extract a very high number of parameters to describe it. Those parameters are usually very similar, if not identical, for each patch of the input area. they are usually low-quality by themselves, and only their high numbers makes them useful for a classification task. However, no human would be able to correlate all the data to extract anything useful, or to build a distance function, or a threshold on what is "similar" or "not similar". One would have to manually select and set thousands/tens of thousands of thresholds. This is why texture descriptors are usually processed by some data-mining algorithms, like SVD, ADA Boost, etc. Their role is, given a number of positive samples, and a number of negative samples, to find a threshold between the two classed that best separates them. Some algorithms (boosting) even try to select those features that seem to be more useful for classification and reject those that do not add useful info.

Texture descriptors work well with objects that are predefined and can easily be described by a fixed area in a picture: a car, a face, a letter, a sign.

Keypoint descriptors

Examples: SIFT/SURF/FREAK/ORB/ASIFT/AGAST/ a thousand others...

How they work:

Given a random image, they compute for each pixel a function of "interestingness" - that is a measure of how likely is to uniquely recognize that point in another image. For this, they analyse the area around the pixel and calculate all kinds of crazy statistics.

After all this is done, the algorithm selects a number of the most interesting ones and calculates for them the same (or another) set of parameters, to be used as description. (Like a name, or a hash function describing each point).

The final step of the algorithm is to match two or more images to see whether they contain the same information (the same keypoints) - is the San Francisco Bridge in the two pics? Are they superimposing? Note that, unlike the texture algorithms, keypoints make no assumption about the area of an object - they do not need and do not output contour information, or location information about an object, but about automatically-selected points.

This makes them very useful to process random pics and to measure similarity between them. It is of little use if you want to detect cats, but it is great to catch someone who posted pics with your filthy room on the internet.

Unlike the texture descriptor, here you can easily set and understand output parameters - you can accept a match between two pics if a number of keypoints are matched and ...

more

Thanks man, really useful infos! If you could provide a little example on how to train SVM (or adaboost if it's supported by HOGDescriptor) i would grealty appreciate it!

( 2012-07-28 13:10:58 -0500 )edit

Traincascade.exe is just what you're looking for. The term "cascade" implies that it uses Ada Boost for classification. I know there are SVM training algorithms, but I did not use them, and I do not know whether tey are available in OpenCV

( 2012-07-28 13:20:19 -0500 )edit
1

If you would like an example of how to train an SVM using OpenCV then you can refer to Chapter 9 of the OpenCV Reference Manual. I personally like LibSVM's version, it's much easier to understand and use. Here is guide to using it, http://www.csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf.

SVM's are great as a classification tool, so if you would like to classify objects into specific groups then it works great. It works even better if you just want a yes or no answer when classifying objects.

@sammy, Great summary, it's very useful.

( 2012-07-31 08:47:22 -0500 )edit

in your last paragraph @sammy you said "Unlike the texture descriptor, here you can easily set and understand output parameters - you can accept a match between two pics if a number of keypoints are matched and a homography can be determined between them." how can I choose that value? if a number of keypoints are matched? we need at list how many keypoints paired|/matched to assume a between two images there is the same object? please explain.

( 2015-11-04 08:56:21 -0500 )edit

This is a great explanation, many things more clear for me. Thank you very much.

( 2017-02-09 02:12:10 -0500 )edit

Why is there 1000 thresholds to set in hog? and what do you mean by homography? and how is it determined?

( 2017-12-14 05:13:15 -0500 )edit

Official site

GitHub

Wiki

Documentation