Detecting objects in an image has always been the hot trend among the computer vision enthusiasts. What initially began as a task of detecting a single object in an image has today extended to large scale competitions that utilize millions of images for training classifiers that can detect more than a hundred categories of objects in a single image. For example, the ILSVRC2014 (ImageNet Large Scale Visual Recognition Challenge) that dare competitors to detect up-to 200 object categories in a single image.
Lowe's SIFT (Scale Invariant Feature Transform) was one of the earliest attempt at matching objects in an unknown image with that of the training image. SIFT, although still considered the best method for object detection fails when an interesting object suffers from in-class variation. An alternative was suggested by Dalal and Triggs in their seminal research work on human detection: "Histogram of Oriented Gradients for Human Detection". The original paper can be found here.
The paper describes an algorithm that can handle the variation in human postures, differently colored clothing, and viewing angle while detecting human figures in an image. To say it simply, the algorithm could identify humans (or any other object) irrespective of its posture and color variation. Here I explain the implementation in detail.
Lowe's SIFT (Scale Invariant Feature Transform) was one of the earliest attempt at matching objects in an unknown image with that of the training image. SIFT, although still considered the best method for object detection fails when an interesting object suffers from in-class variation. An alternative was suggested by Dalal and Triggs in their seminal research work on human detection: "Histogram of Oriented Gradients for Human Detection". The original paper can be found here.
The paper describes an algorithm that can handle the variation in human postures, differently colored clothing, and viewing angle while detecting human figures in an image. To say it simply, the algorithm could identify humans (or any other object) irrespective of its posture and color variation. Here I explain the implementation in detail.
Creating the HOG feature descriptor
The authors compute weighted histograms of gradient orientations over small spatial neighborhoods, gather these neighboring histograms into local groups and contrast normalize them.
Following are the steps:
a) Compute centered horizontal and vertical gradients with
no smoothing.
b) Compute gradient orientation and
magnitudes.
- For color image, pick the color channel with the highest gradient magnitude for each pixel.
c) For a 64x128 image,
- Divide the image into 16x16 blocks of 50% overlap. (7x15 = 105 blocks in total)
- Each block should consist of 2x2 cells with 8x8
d) Quantize the gradient orientation into
9 bins
- The vote is the gradient magnitude
- Interpolate votes tri-linearly between neighbouring bin center
- The vote can also be weighted by a Gaussian to downweight the pixels near the edge of the block
The entire technique was summarized nicely in a lecture by Dr. Mubarak Shah (Professor University of California, Florida)
Training Methodology
We construct a SVM classifier using positive images (containing human figures) and negative images (no human figures) using the INRIA dataset. All the images (positive and negative were resized to 128x64 pixel size and HOG feature descriptors were computed for each one of them. The images were fed into the classifier and trained using supervised learning.
The INRIA dataset (webpage link) was constructed which contained 1800 pedestrian images, in diverse environments, lighting conditions and large range of poses and backgrounds. The INRIA dataset is much more challenging then the initially used MIT pedestrian dataset.
For training 1208 128x64 size positive images of humans were taken, all cropped from a varied set of photos.
Similarly, 1218 negative images were taken containing no human figures.
For training 1208 128x64 size positive images of humans were taken, all cropped from a varied set of photos.
Similarly, 1218 negative images were taken containing no human figures.
Sliding Window Approach
The image is scanned at all scales and positions. Initially windows are extracted at the lowest scale i.e. 128x64 size and then increased every time by a ratio of 1.05. HOG is computed for every part of the image inside the detection window and fed into the classifier.
Results
Some result as obtained after non-maximal suppression of the detected windows.
Once the required dataset is provided, the above algorithm can also used for detecting interest objects other than human figures (e.g. Cars and motorbikes). Algorithm can handle the situation of in-class variation along with efficient performance. The HOG descriptor suggested by Dalal and Triggs today is at the frontiers of object recognition systems.
Nice work Sanyam. Can you share the source code @ tarunramchandani2012@gmail.com
ReplyDeleteFirst off, great work !!
ReplyDeleteWhen you say run the detector at different scales, you actually mean scale the images at different sizes, right? Since the detector is trained for 128*64 size , we cannot actually scale the detector on different sizes, can we?
Correct me if I'm wrong but I was under impression that running detector on different scale meant scaling the image so that 128*64 sized window covers larger portion of image, not scaling the detector window itself.
Thanks
can you send me matlab code please? like oracles r not guesses said am little bit confused so maybe the code will make it clear for me . thank you
ReplyDeletemy mail is :
khribi.hamza@gmail.com
can you send me matlab code please? Thank you. My mail is :
ReplyDeletequocduypt95@gmail.com
It's a nice work. Can u plz send me the source code? My mail id is pal.ashoktaru@gmail.com. I am trying to work something on computer vision.4
ReplyDeletevery nice. Can you please send me the source code @ ayad.albahr@gmail.com
ReplyDeleteIt's a nice work. Can u plz send me the source code? My mail id is yoghurt.hyy@gmail.com.
ReplyDeleteI am trying to work something on VS2015.
nice work. can you send me the code to detect the missing persons in a room. email me the code at: asad.ejaz.5891@gmail.com
ReplyDeleteHello, thanks for the demonstration. Does any of you get the code and can send it to me at wachab.nea@gmail.com
ReplyDeleteThank you
sir with all of my respect, can you send the source code,please.
ReplyDeletei have a project and i stuck on the sliding window
if you dont mind please send the code to rezaazhari11@gmail.com
Nice work, may you please send me the source code to arwag.cs@gmail.com. I'm working on classification task that depends on HOG features.
ReplyDeletecan you send me matlab code please? Thank you. My mail is :
ReplyDeletenguyentanlinh0402@gmail.com
can you send me matlab code please? Thank you. My mail is :
ReplyDeletetimoumirassem@gmail.com
This comment has been removed by the author.
ReplyDeletecan you send me matlab code please? I am trying to work something on Pedestrian Detection. Thank you. My mail is: carmen_2012@hotmail.com
ReplyDeleteCongrats! Nice work! Could you please send me the code? mail: j.bernechea.quilis@gmail.com
ReplyDeletecan you send me matlab code please? I am trying to work something on Peole on Detection. Thank you, so much. My mail is: luanfelcomp@gmail.com
ReplyDeletecan you send me matlab code please? I am working on People Detection by HOG. My email is: afarzana4@live.utm.my....Thanks in advance
ReplyDeletePlease send me source code of it.
ReplyDeleteMail id harshsindhwa@yahoo.com
Please sanyamgarg share the code, i'm working on something like it/
ReplyDeleteNice work. Can you share the Matlab code, my email is shahbano.ather@gamil.com
ReplyDeleteThanks in advance.
Please send me source code of it.
ReplyDeleteMail id djouhainadjouhainabellakehal17@gmail.com
Please send me source code of it.
ReplyDeleteMail id djouhainadjouhainabellakehal17@gmail.com
Please send me source code of it.
ReplyDeleteMail id djouhainadjouhainabellakehal17@gmail.com
Please share the source, im working on he same field.
ReplyDeleteE mail: shauvick497.smit@gmail.com
Thank you
pls send the source code for python
ReplyDeletemail id -svkavi1999@gmail.com
Can you please share the matlab code,my mail id is dharandhavamani26@gmail.com.
ReplyDeletecan you please give the matlab code to 'akhilagopan890@gmail.com'
ReplyDeletecan you please give the matlab code to 'danghuyvms@gmail.com'.
ReplyDeleteThanks!
Can you please share the matlab code mail id : greeshmaa02@gmail.com
ReplyDeleteCan you plesse send me the mathlab codes.
ReplyDeleteicebed1550@gmail.com
Hey! It looks you've got a great work, congrats! Can you send me the matlab codes, please? Thank you much in advance!
ReplyDeleteHey! It looks you've got a great work, congrats! Can you send me the matlab codes, please? Thank you much in advance!
ReplyDeletefurkannargul98@gmail.com
Hey! It looks you've got a great work, congrats! Can you send me the matlab codes, please? Thank you much in advance!
ReplyDeletehonghun0622@gmail.com