Escolar Documentos
Profissional Documentos
Cultura Documentos
VctorEmanuelRosMartnez
Table of contents
Tableofcontents
Introduction
Objective
Justification
Development
Results
FutureWork
Conclusions
References
Introduction
Detecting humans is a task that has a great importance and value in the field of
computervision. For multiple purposes, from videosurveillancesystemstocarswith
automatic pilot, there have been continuous improvements in the techniques for
detectinghumans.
Recently, since the last decade, the techniques such as the HOG descriptor have
beenimplemented toachievethispurpose.Alongwiththecapabilitiesofaclassifier,
the HOGdescriptor, can really determinewhether an objectisahumanbodyornot.
One ofthemost used classifiers is the SVM.AnSVM(SupportVectorMachine)isa
supervisedlearningalgorithmthatconstructsahyperplanetoclassifyelements.
In this work, I make an implementation of the HOG descriptor and the SVMs
includedintheOpenCVlibraryforpython.
Objective
Concisely, the objective of this work is to get a reasonable understanding of the
methods and techniques used forpeopledetection, inadditiontogetanoverviewof
Justification
Therearemany applicationsofpedestriandetectionbuttheimportanceofeachone
is what gives value to the work. The video surveillance systems, used in banks,
airports and stores are one of the most outstanding examples, but also systems
managed via automaticpilot, such as cars and motorcycles,candraw some benefit
fromthedevelopmentofthisarea.
VideoSurveillanceSystems.Imagefromhttp://www.siebelresearch.de/
Development
Firstly, I will explain the process to get the HOG Descriptor. The HOG descriptor
(Histogram of Oriented Gradient) is based on the gradient orientation of regions in
theimage.Basically,thisistheprocedure.
1. Theimageisdividedincells.
2. Computegradientorientationofeachpixel.
3. Thecellsarediscretizedtakingintoaccountthegradientorientation.
4. Eachcellspixelvotesfortheorientationbasedonthegradientorientation.
5. Thecellsaregroupedinblocks.
6. Histogramsarenormalizedforeachblock.
7. Thedescriptoristhesetofnormalizedhistograms.
HOGdescriptor.Imagefromhttps://software.intel.com
TheSVMdefinesahyperplaneforclassification.
"Linearsvmscatterplot"byQwertyusWikimediaCommons
ThisispartofthecodethatimplementstheHOGdescriptorwiththetrainedSVM.
#Createahogdescriptorobject.
hog=cv2.HOGDescriptor()
#SetthecoefficientsfortheSVM
hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
#Detectpeopleintheimage
hogParams={'winStride':(0,0),'padding':(0,0),'scale':1.05}
found=hog.detectMultiScale(bigger_img,**hogParams)
Thecodeforselectingtheregionofinterest(ROI)isalsoimportant.
defselectROI(event,x,y,flags,params):
globalroi
ifevent==cv2.EVENT_LBUTTONUP:
roi.append((x,y))
iflen(roi)==2:
cv2.rectangle(img,roi[0],roi[1],(255,0,0),2)
# Gaussian filter and background subtraction, both seem to negatively affectin the
detection
#blur=cv2.GaussianBlur(img,(3,3),0)
#fgmask=fgbg.apply(img,None,0.5)
#fgmask=cv2.morphologyEx(fgmask,cv2.MORPH_OPEN,kernel)
Finally, the bounding boxes are drawn in the frame and the number of people
detectedisshowninthewindow.
#Asubroutinetogetdifferentcolors
col=colorsfile.color(noofpersons)
#Boundingbox
foriinxrange(0,noofpersons):
person=found[0][i].tolist()
x=person[0]
y=person[1]
xf=person[0]+person[2]
yf=person[1]+person[3]
cv2.rectangle(img,(x,y),(xf,yf),col[i],1)
cv2.putText(img,"Numberofpersons:"+str(noofpersons),(0,30),
cv2.FONT_HERSHEY_SIMPLEX,1,(255,255,255),2)
Results
Selecting different areas of the same video. I can select a region of interest inthe
video.Theselectioncanberestartedbeforestartingthedetectionusingthekeyr.
Future Work
Conclusions
References
Dalal, N., & Triggs, B. (2005, June). Histograms of oriented gradients for human
detection. In Computer Vision and Pattern Recognition, 2005. CVPR 2005. IEEE
ComputerSocietyConferenceon(Vol.1,pp.886893).IEEE.
Rosebrock, A. (2015, March 9). Capturing mouse click events with Python and
OpenCV
PyImageSearch.
Retrieved
May
25,
2015,
from
http://www.pyimagesearch.com/2015/03/09/capturingmouseclickeventswithpytho
nandopencv/