I have followed the sample code from the code project to create a face recognition system using EMGUCV. I have trained the database with 2 people and each person has 10 images. When the webcam detects those people and able to show the name correctly but the problem is the third person whose do not exist in trained database detect by webcam, it will take the nearest face and display the name on it instead of show "Unknown". How can I improve the accuracy? I have tried to change the threshold value but didn't help. What's going wrong?
currentFrame = grabber.QueryFrame().Resize(320, 240,
Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
currentFrame.SmoothBlur(320, 240);
gray = currentFrame.Convert<Gray, Byte>();
Rectangle[] facesDetected = face.DetectMultiScale(gray, 1.2, 10, new
Size(50, 50), Size.Empty);
for (int j = 0; j < facesDetected.Length; j++)
{
facesDetected[j].X += (int)(facesDetected[j].Height * 0.15);
facesDetected[j].Y += (int)(facesDetected[j].Width * 0.22);
facesDetected[j].Height -= (int)(facesDetected[j].Height * 0.3);
facesDetected[j].Width -= (int)(facesDetected[j].Width * 0.35);
result = currentFrame.Copy(facesDetected[j]).Convert<Gray, byte>().Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
result._EqualizeHist();
currentFrame.Draw(facesDetected[j], new Bgr(Color.Red), 2);
if (trainingImages.ToArray().Length != 0)
{
recog = new LBPHFaceRecognizer(1, 10, 8, 8, 10000);
//recog = new EigenFaceRecognizer(0, 3500);
//recog = new FisherFaceRecognizer(0, 3500);
recog.Train(trainingImages.ToArray(), Names_List_ID.ToArray());
FaceRecognizer.PredictionResult ER = recog.Predict(result);
if (ER.Label == -1)
{
name = "Unknown";
}
else
{
name = taglabels[ER.Label];
}
currentFrame.Draw(name, ref font, new Point(facesDetected[j].X - 2, facesDetected[j].Y - 2), new Bgr(Color.Green));
}
}
You can threshold the returned distance/confidence. You need a verification set of images, new images of the trained faces and some random faces, get the distance and set the threshold value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With