Thursday 1 May 2014

Pedestrian Detection: Why Dalal and Triggs are the godfathers of today's computer vision family!

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.

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
e) Concatenate histograms (Feature Dimension: 105x4x9 = 3,780)


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. 


Choosing the Training Dataset 

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.


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.  


34 comments:

  1. Nice work Sanyam. Can you share the source code @ tarunramchandani2012@gmail.com

    ReplyDelete
  2. First off, great work !!
    When 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

    ReplyDelete
  3. 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
    my mail is :
    khribi.hamza@gmail.com

    ReplyDelete
  4. can you send me matlab code please? Thank you. My mail is :
    quocduypt95@gmail.com

    ReplyDelete
  5. 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

    ReplyDelete
  6. very nice. Can you please send me the source code @ ayad.albahr@gmail.com

    ReplyDelete
  7. It's a nice work. Can u plz send me the source code? My mail id is yoghurt.hyy@gmail.com.
    I am trying to work something on VS2015.

    ReplyDelete
  8. 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

    ReplyDelete
  9. Hello, thanks for the demonstration. Does any of you get the code and can send it to me at wachab.nea@gmail.com
    Thank you

    ReplyDelete
  10. sir with all of my respect, can you send the source code,please.
    i have a project and i stuck on the sliding window
    if you dont mind please send the code to rezaazhari11@gmail.com

    ReplyDelete
  11. 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.

    ReplyDelete
  12. can you send me matlab code please? Thank you. My mail is :
    nguyentanlinh0402@gmail.com

    ReplyDelete
  13. can you send me matlab code please? Thank you. My mail is :
    timoumirassem@gmail.com

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. can you send me matlab code please? I am trying to work something on Pedestrian Detection. Thank you. My mail is: carmen_2012@hotmail.com

    ReplyDelete
  16. Congrats! Nice work! Could you please send me the code? mail: j.bernechea.quilis@gmail.com

    ReplyDelete
  17. can 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

    ReplyDelete
  18. can you send me matlab code please? I am working on People Detection by HOG. My email is: afarzana4@live.utm.my....Thanks in advance

    ReplyDelete
  19. Please send me source code of it.
    Mail id harshsindhwa@yahoo.com

    ReplyDelete
  20. Please sanyamgarg share the code, i'm working on something like it/

    ReplyDelete
  21. Nice work. Can you share the Matlab code, my email is shahbano.ather@gamil.com
    Thanks in advance.

    ReplyDelete
  22. Please send me source code of it.
    Mail id djouhainadjouhainabellakehal17@gmail.com

    ReplyDelete
  23. Please send me source code of it.
    Mail id djouhainadjouhainabellakehal17@gmail.com

    ReplyDelete
  24. Please send me source code of it.
    Mail id djouhainadjouhainabellakehal17@gmail.com

    ReplyDelete
  25. Please share the source, im working on he same field.
    E mail: shauvick497.smit@gmail.com
    Thank you

    ReplyDelete
  26. pls send the source code for python
    mail id -svkavi1999@gmail.com

    ReplyDelete
  27. Can you please share the matlab code,my mail id is dharandhavamani26@gmail.com.

    ReplyDelete
  28. can you please give the matlab code to 'akhilagopan890@gmail.com'

    ReplyDelete
  29. can you please give the matlab code to 'danghuyvms@gmail.com'.
    Thanks!

    ReplyDelete
  30. Can you please share the matlab code mail id : greeshmaa02@gmail.com

    ReplyDelete
  31. Can you plesse send me the mathlab codes.
    icebed1550@gmail.com

    ReplyDelete
  32. Hey! It looks you've got a great work, congrats! Can you send me the matlab codes, please? Thank you much in advance!

    ReplyDelete
  33. Hey! It looks you've got a great work, congrats! Can you send me the matlab codes, please? Thank you much in advance!
    furkannargul98@gmail.com

    ReplyDelete
  34. Hey! It looks you've got a great work, congrats! Can you send me the matlab codes, please? Thank you much in advance!
    honghun0622@gmail.com

    ReplyDelete