Ejemplo n.º 1
0
        private void button4_Click(object sender, EventArgs e)
        {
            bool  matched = false;
            Int32 err     = 0;

            err = m_FPM.MatchTemplate(m_RegMin1, m_RegMin2, m_SecurityLevel, ref matched);

            if ((err == (Int32)SGFPMError.ERROR_NONE))
            {
                if (matched)
                {
                    // Save template after merging two template - m_FetBuf1, m_FetBuf2
                    Byte[] merged_template;
                    Int32  buf_size = 0;

                    m_FPM.GetTemplateSizeAfterMerge(m_RegMin1, m_RegMin2, ref buf_size);
                    merged_template = new Byte[buf_size];
                    m_FPM.MergeAnsiTemplate(m_RegMin1, m_RegMin2, merged_template);

                    if (m_StoredTemplate == null)
                    {
                        m_StoredTemplate = new Byte[buf_size];
                        merged_template.CopyTo(m_StoredTemplate, 0);
                    }
                    else
                    {
                        Int32 new_size = 0;
                        err = m_FPM.GetTemplateSizeAfterMerge(m_StoredTemplate, merged_template, ref new_size);

                        Byte[] new_enroll_template = new Byte[new_size];

                        err = m_FPM.MergeAnsiTemplate(merged_template, m_StoredTemplate, new_enroll_template);

                        m_StoredTemplate = new Byte[new_size];

                        new_enroll_template.CopyTo(m_StoredTemplate, 0);
                    }



                    StatusBar.Text = "Template registration success";


                    ////////////////////////////////////
                    PictureBox picturebox3 = new PictureBox();

                    string appPath2 = Path.GetDirectoryName(Application.ExecutablePath);
                    ///create the connection string
                    string connString = @"Data Source= " + appPath2 + @"\DBUC.s3db ;Version=3;";

                    //create the database query
                    string query = "SELECT * FROM Usuarios where Usuario = '" + textBox1.Text + "'";

                    //create an OleDbDataAdapter to execute the query
                    System.Data.SQLite.SQLiteDataAdapter dAdapter = new System.Data.SQLite.SQLiteDataAdapter(query, connString);

                    //create a command builder
                    System.Data.SQLite.SQLiteCommandBuilder cBuilder = new System.Data.SQLite.SQLiteCommandBuilder(dAdapter);

                    //create a DataTable to hold the query results
                    DataTable dTable = new DataTable();
                    //fill the DataTable
                    dAdapter.Fill(dTable);
                    dAdapter.Update(dTable);

                    if (dTable.Rows.Count >= 1)
                    {
                        DataRow Row = dTable.Rows[0];

                        if (Row["Huella"] != null)
                        {
                            System.Byte[] fp_image = (System.Byte[])Row["Huella"];

                            ///////////////////////////////////////////////////

                            Int32 error    = (Int32)SGFPMError.ERROR_NONE;
                            Int32 img_qlty = 0;

                            m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);

                            if (error == (Int32)SGFPMError.ERROR_NONE)
                            {
                                DrawImage(fp_image, picturebox3);

                                SGFPMFingerInfo finger_info = new SGFPMFingerInfo();
                                finger_info.FingerNumber   = (SGFPMFingerPosition)1;
                                finger_info.ImageQuality   = (Int16)img_qlty;
                                finger_info.ImpressionType = (Int16)SGFPMImpressionType.IMPTYPE_LP;
                                finger_info.ViewNumber     = 1;

                                // Create template
                                error = m_FPM.CreateTemplate(finger_info, fp_image, m_VrfMin);

                                if (error == (Int32)SGFPMError.ERROR_NONE)
                                {
                                    StatusBar.Text = "Verification image is captured";

                                    if (m_StoredTemplate == null)
                                    {
                                        StatusBar.Text = "No data to verify";
                                        return;
                                    }

                                    string[] fingerpos_str = new string[]
                                    {
                                        "Unknown finger",
                                        "Right thumb",
                                        "Right index finger",
                                        "Right middle finger",
                                        "Right ring finger",
                                        "Right little finger",
                                        "Left thumb",
                                        "Left index finger",
                                        "Left middle finger",
                                        "Left ring finger",
                                        "Left little finger"
                                    };


                                    SGFPMFingerPosition finger_pos = SGFPMFingerPosition.FINGPOS_UK;
                                    bool finger_found = false;

                                    SGFPMANSITemplateInfo sample_info = new SGFPMANSITemplateInfo();
                                    err = m_FPM.GetAnsiTemplateInfo(m_StoredTemplate, sample_info);

                                    for (int i = 0; i < sample_info.TotalSamples; i++)
                                    {
                                        matched = false;
                                        err     = m_FPM.MatchAnsiTemplate(m_StoredTemplate, i, m_VrfMin, 0, m_SecurityLevel, ref matched);
                                        if (matched)
                                        {
                                            finger_found = true;
                                            finger_pos   = (SGFPMFingerPosition)sample_info.SampleInfo[i].FingerNumber;
                                            break;
                                        }
                                    }

                                    if (err == (Int32)SGFPMError.ERROR_NONE)
                                    {
                                        if (finger_found)
                                        {
                                            StatusBar.Text  = "The matched data found. Finger position: " + fingerpos_str[(Int32)finger_pos];
                                            textBox2.Text   = Row["Contrasena"].ToString();
                                            button1.Enabled = true;
                                            button1.PerformClick();
                                        }
                                        else
                                        {
                                            StatusBar.Text = "Cannot find a matched data";
                                        }
                                    }
                                    else
                                    {
                                        StatusBar.Text = "MatchAnsiTemplate() Error : " + err;
                                    }
                                }

                                else
                                {
                                    StatusBar.Text = "GetMinutiae() Error : " + error;
                                }
                            }
                            else
                            {
                                StatusBar.Text = "GetImage() Error : " + error;
                            }
                        }
                        else
                        {
                            MessageBox.Show("No hay huella con la cual comparar");
                        }
                        ////////////////////////////////////////////////
                    }
                    else
                    {
                        MessageBox.Show("El usuario no existe U olvido colocarlo");
                    }
                }
                else
                {
                    StatusBar.Text = "Template registration failed";
                }
            }
            else
            {
                StatusBar.Text = "MatchTemplate() Error: " + err;
            }
        }
Ejemplo n.º 2
0
        /////////////////////////////////////
        private void BtnRegister_Click(object sender, System.EventArgs e)
        {
            bool  matched = false;
            Int32 err     = 0;

            err = m_FPM.MatchTemplate(m_RegMin1, m_RegMin2, m_SecurityLevel, ref matched);

            if ((err == (Int32)SGFPMError.ERROR_NONE))
            {
                if (matched)
                {
                    // Save template after merging two template - m_FetBuf1, m_FetBuf2
                    Byte[] merged_template;
                    Int32  buf_size = 0;

                    if (m_useAnsiTemplate)
                    {
                        m_FPM.GetTemplateSizeAfterMerge(m_RegMin1, m_RegMin2, ref buf_size);
                        merged_template = new Byte[buf_size];
                        m_FPM.MergeAnsiTemplate(m_RegMin1, m_RegMin2, merged_template);
                    }
                    else
                    {
                        m_FPM.GetIsoTemplateSizeAfterMerge(m_RegMin1, m_RegMin2, ref buf_size);
                        merged_template = new Byte[buf_size];
                        m_FPM.MergeIsoTemplate(m_RegMin1, m_RegMin2, merged_template);
                    }

                    if (m_StoredTemplate == null)
                    {
                        m_StoredTemplate = new Byte[buf_size];
                        merged_template.CopyTo(m_StoredTemplate, 0);
                    }
                    else
                    {
                        Int32 new_size = 0;

                        if (m_useAnsiTemplate)
                        {
                            err = m_FPM.GetTemplateSizeAfterMerge(m_StoredTemplate, merged_template, ref new_size);
                        }
                        else
                        {
                            err = m_FPM.GetIsoTemplateSizeAfterMerge(m_StoredTemplate, merged_template, ref new_size);
                        }

                        Byte[] new_enroll_template = new Byte[new_size];

                        if (m_useAnsiTemplate)
                        {
                            err = m_FPM.MergeAnsiTemplate(merged_template, m_StoredTemplate, new_enroll_template);
                        }
                        else
                        {
                            err = m_FPM.MergeIsoTemplate(merged_template, m_StoredTemplate, new_enroll_template);
                        }

                        m_StoredTemplate = new Byte[new_size];

                        new_enroll_template.CopyTo(m_StoredTemplate, 0);
                    }

                    // Let's display ANSI/ISO template Info
                    for (int i = 0; i < m_RadioButton.Length; i++)
                    {
                        m_RadioButton[i].Checked = false;
                    }

                    if (m_useAnsiTemplate)
                    {
                        SGFPMANSITemplateInfo sample_info = new SGFPMANSITemplateInfo();
                        err = m_FPM.GetAnsiTemplateInfo(m_StoredTemplate, sample_info);
                        for (int i = 0; i < sample_info.TotalSamples; i++)
                        {
                            m_RadioButton[(Int32)sample_info.SampleInfo[i].FingerNumber].Checked = true;
                        }
                    }
                    else
                    {
                        SGFPMISOTemplateInfo sample_info = new SGFPMISOTemplateInfo();
                        err = m_FPM.GetIsoTemplateInfo(m_StoredTemplate, sample_info);
                        for (int i = 0; i < sample_info.TotalSamples; i++)
                        {
                            m_RadioButton[(Int32)sample_info.SampleInfo[i].FingerNumber].Checked = true;
                        }
                    }

                    StatusBar.Text = "Template registration success";
                }
                else
                {
                    StatusBar.Text = "Template registration failed";
                }
            }
            else
            {
                StatusBar.Text = "MatchTemplate() Error: " + err;
            }
        }