Ask Your Question
1

Body detection using haarcascade

asked Sep 15 '14

Christosh gravatar image

I am trying to detect body from images using haar cascades. I am using python code in order to do so, my code is the following:

import numpy as np
import sys
import cv2

body_cascade = cv2.CascadeClassifier('cascades/haarcascade_upperbody.xml')
img = cv2.imread('body/body4.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

faces = body_cascade .detectMultiScale(gray, 1.1, 8)

for (x,y,w,h) in faces:
   cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2)
   roi_gray = gray[y:y+h, x:x+w]
   roi_color = img[y:y+h, x:x+w]

I ve tested several images, the three cascades for body several scalefactors. However, it seems not finding the body in any image. Am I doing something wrong in the parameters of detection? When I tried frontface cascades everything worked fine.

Preview: (hide)

Comments

2

you could try to reduce the minneighbour param in detectMultiScale. 3 instead of 8 maybe.

berak gravatar imageberak (Sep 15 '14)edit

Also increasing the scale step to 1.05 (more finer stages) can increase detection chance!

StevenPuttemans gravatar imageStevenPuttemans (Jul 26 '16)edit

2 answers

Sort by » oldest newest most voted
0

answered Sep 20 '17

Try this for me its working after resizing and decreasing the neighbour


cam=cv2.VideoCapture(0)

while True:

ret, frame = cam.read()
frame=imutils.resize(frame, width=min(100, frame.shape[1]))
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
upper=fc.detectMultiScale(gray,1.1,1)
#print lips
for (a,b,c,d) in upper:
    cv2.rectangle(frame,(a,b),(a+c,b+d),(0,0,255),2)
print len(upper)
cv2.imshow('detect',frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
    break

cam.release() cv2.destroyAllWindows()

Preview: (hide)
0

answered Jul 26 '16

the solution is.

i read a description in haarcascade_fullbody.xml in line 132 says : hese detectors will also work at very low image resolutions

may be you must try to resize image first. see in description in the first line of xml file says : 14x28 fullbody detector (see the detailed description below).

hope it help.

Preview: (hide)

Comments

Wow wait, if the guys is not providing the Size properties, then the function is multiscale on the scaled image pyramid, so your point would be useless ...

StevenPuttemans gravatar imageStevenPuttemans (Jul 26 '16)edit

Question Tools

Stats

Asked: Sep 15 '14

Seen: 13,026 times

Last updated: Jul 26 '16