Ask Your Question

ben_g's profile - activity

2014-11-08 13:19:31 -0600 asked a question face detection not detecting any faces

Hi,

I'm trying to get face detection to work with python and openCV on a raspberry pi for a school project. Unfortunately, I can't get my script to work. It opens the camera correctly, but it never detects faces on it. I've tried feeding it (higher-quality) images that contained faces from google, but it didn't seem to be able to detect any faces on that one either. The script also seems to be way to fast to be actually looking for faces too, but I tried executing it line by line in the command line and it doesn't seem to error anyware and untill the face detection occurs, none of the variables are nulltypes.

Here's my script: [code] print "Loading..."

import cv2 import sys import cv2.cv as cv

faceCascade = cv2.CascadeClassifier('face.xml')

video_capture = cv2.VideoCapture(0) video_capture.set(3, 1280.) video_capture.set(4, 720.)

while True: # Capture frame-by-frame print "Taking picture..." ret, frame = video_capture.read()

gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

print "looking for faces..."
faces = faceCascade.detectMultiScale(gray, 1.3, 4, cv2.cv.CV_HAAR_SCALE_IMAGE, (20,20))
for f in faces:
    print "Face found at " + str(f.coordinates())
if len(faces)==0:
    print "No faces found!"
print "cycle completed!"

When everything is done, release the capture

video_capture.release() cv2.destroyAllWindows() [/code] Does anyone see anything wrong with it?