Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version 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:

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 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 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)


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 "", line 98, in <module> App(video_src, dataset_fn).run() File "", line 74, in run prediction = self.predictor.predict(face) File "../../facerec/", line 21, in predict return self.classifier.predict(q) File "../../facerec/", 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.