Ask Your Question

coredumped's profile - activity

2012-07-16 11:43:06 -0600 received badge  Scholar (source)
2012-07-16 07:20:07 -0600 received badge  Notable Question (source)
2012-07-13 01:56:57 -0600 received badge  Popular Question (source)
2012-07-12 09:09:22 -0600 asked a question videofacerec.py example help

Hello, I'm currently doing some work in face recognition with small training data samples (typically only one per person). I was initially trying to do face recognition with eigenfaces but getting terrible results, and was guided to use Local Binary Patterns Histograms by this stack overflow post: http://stackoverflow.com/questions/11315157/opencv-javacv-face-recognition-very-similar-confidence-values

I started to study the libfacerec as suggested and tried to use the facerec_lbph.cpp example which uses the Local Binary Patterns Histograms to recognize faces. However, my results were still very poor. I suspect the reason for this is that my preprocessing method for the images was applying grayscale and histogram equalization. The stack overflow post linked above suggested using the TanTriggs method to preprocess the images in order to achieve good results. So, some research later, I found https://github.com/bytefish/facerec/blob/master/py/apps/videofacerec/videofacerec.py which seems to be doing what I need in python. From a sample video, detecting the faces in it, and predicting who they might belong to, giving as a second argument to the program, a training set of images.

I must admit, I'm quite new to python, and the fact that there isn't much documentation on this particular example, I'm having trouble making it work.

Currently if I try running it in its original code (The only thing I changed was making so instead of capturing frames from a video file, it captures from a live camera feed) it simply does not detect any faces.. I tested the detector.py code and it works on its own. I started messing around a bit with the code, and by changing the

img = cv2.resize(frame, (frame.shape[1]/2, frame.shape[0]/2), interpolation = cv2.INTER_CUBIC)

to

img = cv2.resize(frame, (frame.shape[1]2, frame.shape[0]2), interpolation = cv2.INTER_CUBIC)

the program is able to detect faces. However, when reaching the predict step

get a prediction

prediction = self.predictor.predict(face)

it gives me this error:

Traceback (most recent call last): File "videofacerec.py", line 98, in <module> App(videosrc, datasetfn).run() File "videofacerec.py", line 74, in run prediction = self.predictor.predict(face) File "../../facerec/model.py", line 21, in predict return self.classifier.predict(q) File "../../facerec/classifier.py", line 38, in predict hist = dict((key,val) for key, val in enumerate(np.bincount(sorted_y)) if val) ValueError: The first argument cannot be empty.

and I am stuck here... Can someone help me to better understand this code, or fix my problem please? Thank you.