Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've tried to code a face recognition program and need some help from the community. The code posted below compiled with no error and the recognizer working if the threshold that i set is 0, if i set the threshold > 0 its display Unknown Face definitely.
I am using 4 training image for a person.
Face in Database :
PersonA:
- PersonA1, PersonA2, PersonA3, PersonA4
PersonB:
- PersonB1, PersonB2, PersonB3, PersonB4
Scenario Example:
If new person (none in database) face detected lets called PersonC, but the program always display name from database between PersonA or PersonB.

How to display new detected face / PersonC as Unknown Face if there are no face in database. Any idea on where have i gone wrong? Thanks in advance.

I'm using emgu cv 2.2.1.1150 with c# 2010 express
imgRecognizer Initialization:
C#
private void AttendanceForm_Load(object sender, EventArgs e)
{
    dbFA = new FRAttendance_DBDataContext();
    timer.Start();
    face = new HaarCascade("haarcascade_frontalface_alt_tree.xml");
    Scanner = new Capture();
    Scanner.QueryFrame();
    Application.Idle += new EventHandler(StartCamera);
    try
    {
    LoadData();
    ImageToList();
    MCvTermCriteria termCrit = new MCvTermCriteria(rowCount, 0.001);
    imgRecognizer = new EigenObjectRecognizer(trainingImages.ToArray(), personsLabel.ToArray(), 1000, ref termCrit);
    }
    catch (Exception err)
    {
        MessageBox.Show(err.ToString());
    }
}

Recognizer Function :
C#
private void btnScan_Click(object sender, EventArgs e)
{
    if (trainingImages.ToArray() != null)
    {
        try
        {
            faceImgLabel = imgRecognizer.Recognize(result);
            if (faceImgLabel.Trim().Equals(""))
            {
                txtHSID.Text = "Unknown";
                txtHSName.Text = "Unknown";
                MessageBox.Show("Unknown Face", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                logMeIn(faceImgLabel);
            }
        }
        catch(Exception errScan)
        {
            MessageBox.Show(errScan.ToString());
            MessageBox.Show("Wait until face detected", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
    }
    else
        MessageBox.Show("No image in collection list", " Information ", MessageBoxButtons.OK, MessageBoxIcon.Information);
        imgScan.Image = result;
}
Posted
Comments
Member 12802137 4-Jan-17 1:27am    
I am having same problem.. If anyone got solution plz help..
id-dixitkolhatkar17@gmail.com

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900