Ejemplo n.º 1
0
 private void savefingerprint()
 {
     try
     {
         Dictionary <int, string>         Fmds = new Dictionary <int, string>();
         Dictionary <int, List <string> > Fids = new Dictionary <int, List <string> >();
         foreach (int finger in mobj.Fmds.Keys)
         {
             Fmds.Add(finger, Fmd.SerializeXml(mobj.Fmds[finger]));
             //MessageBox.Show("extracted fmd :" + Fmd.SerializeXml(mobj.Fmds[finger]), "Alert");
             List <string> fds = new List <string>();
             foreach (Fid fd in mobj.Fids[finger])
             {
                 fds.Add(Fid.SerializeXml(fd));
                 //   MessageBox.Show("extracted fid :"+Fid.SerializeXml(fd), "Alert");
             }
             Fids.Add(finger, fds);
         }
         PersonRepository repo = new PersonRepository();
         bool             b    = repo.saveFingerPrint(Fmds, Fids, pvm.PersonId, null);
         if (b)
         {
             bio_altered = false; MessageBox.Show("FingerPrint Saved Successully", "Alert", MessageBoxButton.OK, MessageBoxImage.Information);
         }
         else
         {
             MessageBox.Show("Error Saving FingerPrint. ", "Alert");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error Saving FingerPrint. Details:" + ex.StackTrace, "Alert");
     }
 }
Ejemplo n.º 2
0
        private void EnrollThread()
        {
            objVariables.count = 0;

            objPrincipal.txtSalida.Dispatcher.BeginInvoke(new Action(delegate()
            {
                objPrincipal.txtSalida.AppendText("Se inicio el registro de huellas. \nColocar el dedo en el lector.");
            }));

            while (!objVariables.reset)
            {
                DataResult <Fmd> resultEnrollment = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, CaptureAndExtractFmd());

                if (resultEnrollment.ResultCode == Constants.ResultCode.DP_SUCCESS)
                {
                    MessageBox.Show("El registro de huella fue exitoso.",
                                    "Aviso",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information,
                                    MessageBoxDefaultButton.Button1);

                    objVariables.serializacion = Fmd.SerializeXml(resultEnrollment.Data);
                    objVariables.count         = 0;
                    objVariables.reset         = true;

                    objPrincipal.EndEnrollment(objVariables.serializacion, true);
                }
            }

            if (objVariables.currentReader != null)
            {
                objVariables.currentReader.Dispose();
            }
        }
Ejemplo n.º 3
0
        public string CrearOperador(Fmd presult, string pcodOperador, string pnombre, string pstatus)
        {
            Operador oOperador;
            string   Mensaje;
            string   huellaConvertida;

            oOperador = CompararHuella(presult, presult);

            if (oOperador.IdOperador == 0)
            {
                huellaConvertida = Convert.ToBase64String(presult.Bytes);

                oOperador             = new Operador();
                oOperador.CodOperador = pcodOperador;
                oOperador.Nombre      = pnombre;
                oOperador.Huella      = huellaConvertida;
                oOperador.Status      = pstatus;

                Mensaje = transaccion.CrearOperador(oOperador);
            }

            else
            {
                Mensaje = "Ya existe un operador registrado con esta huella";
            }

            return(Mensaje);
        }
Ejemplo n.º 4
0
 internal void FillFMDs()
 {
     foreach (string s in FIDs)
     {
         FMDs.Add(Fmd.DeserializeXml(s));
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            MySqlConnection con = null;

            try
            {
                String ConString = ConfigurationManager.ConnectionStrings["biometrics.Properties.Settings.testreportConnectionString"].ConnectionString;
                con = new MySqlConnection(ConString);
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
                con.Open();
                MySqlCommand cmd = con.CreateCommand();
                cmd.CommandText = "Insert into tblfinger (LedgerId, CustomerFinger) VALUES (@ledger, @fingerPrint)";
                cmd.Parameters.AddWithValue("@ledger", ledgerid.Text.ToString());
                cmd.Parameters.AddWithValue("@fingerPrint", Fmd.SerializeXml(firstFinger));
                cmd.ExecuteNonQuery();
                MessageBox.Show("Record Created Successfully");
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Fail To Create User");
                con.Close();
            }
        }
Ejemplo n.º 6
0
        private void getData()
        {
            try
            {
                DataTable dt = db.getFingerPrints();

                foreach (DataRow row in dt.Rows)
                {
                    if (row["Right_Thumb"].ToString() != "")
                    {
                        Fmd temp = Fmd.DeserializeXml(row["Right_Thumb"].ToString());

                        fmds.Add(temp);
                        fmdsDic.Add(temp, (int)row["iPersonID"]);
                    }
                }
                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("There are no finger prints saved in the Database yet!");
                    this.Close();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error occured while getting Finger Prints: " + e.ToString());
            }
        }
Ejemplo n.º 7
0
        public static void LoadAllFmdsUserIDs(string SelectQuery)
        {
            SqlDataReader lReader = ConnectDBnExecuteSelectScript(SelectQuery);
            int           i       = 0;

            // populate all fmds and usernames
            DataTable dt = new DataTable();

            dt.Load(lReader);
            allDBFmd1s   = new Fmd[dt.Rows.Count];
            allDBFmd2s   = new Fmd[dt.Rows.Count];
            allUserNames = new string[dt.Rows.Count];
            // allfingerIDs = new int[dt.Rows.Count];
            if (dt.Rows.Count != 0)
            {
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    if ((dr["FMD1"].ToString().Length != 0) && (dr["FMD2"].ToString().Length != 0))
                    {
                        allDBFmd1s[i]   = Fmd.DeserializeXml(dr["FMD1"].ToString());
                        allDBFmd2s[i]   = Fmd.DeserializeXml(dr["FMD2"].ToString());
                        allUserNames[i] = dr["UserID"].ToString().TrimEnd();
                        i++;
                    }
                }
            }
            lReader.Close();
        }
Ejemplo n.º 8
0
 //method that runs for every capturing
 public void OnCaptured(CaptureResult captureResult)
 {
     try
     {
         // Check capture quality and throw an error if bad.
         if (!fp.CheckCaptureResult(captureResult))
         {
             return;
         }
         else
         {
             //convert to a valid finger print first
             DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
             if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
             {
                 throw new Exception(resultConversion.ResultCode.ToString());
             }
             else
             {
                 //if it succesfully convert then display for user to see
                 // Create bitmap - this part display the captured on screen
                 foreach (Fid.Fiv fiv in captureResult.Data.Views)
                 {
                     SendMessage(Action.SendBitmap, fp.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                 }
                 firstFinger = resultConversion.Data;
             }
         }
     }
     catch (Exception ex)
     {
         // Send error message, then close form
         SendMessage(Action.SendMessage, "Error:  " + ex.Message);
     }
 }
Ejemplo n.º 9
0
        public static void LoadAllFmdsUserIDs(string SelectQuery)
        {
            SqlDataReader lReader = ConnectDBnExecuteSelectScript(SelectQuery);

            // populate all fmds and usernames
            DataTable dt = new DataTable();

            dt.Load(lReader);

            if (dt.Rows.Count != 0)
            {
                allDBFmd1s   = new Fmd[dt.Rows.Count];
                allUserNames = new string[dt.Rows.Count];

                int i = 0;

                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    string fmd1 = dr[1].ToString();

                    allUserNames[i] = dr[0].ToString();
                    allDBFmd1s[i]   = Fmd.DeserializeXml(fmd1);

                    i++;
                }
            }

            lReader.Close();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult))
                {
                    return;
                }

                SendMessage(Action.SendMessage, "A finger was captured.");

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                if (count == 0)
                {
                    rightIndex = resultConversion.Data;
                    count     += 1;
                    SendMessage(Action.SendMessage, "Now place your right thumb on the reader.");
                }
                else if (count == 1)
                {
                    rightThumb = resultConversion.Data;
                    count     += 1;
                    SendMessage(Action.SendMessage, "Now place any finger on the reader.");
                }
                else if (count == 2)
                {
                    anyFinger = resultConversion.Data;
                    Fmd[] fmds = new Fmd[2];
                    fmds[0] = rightIndex;
                    fmds[1] = rightThumb;

                    // See the SDK documentation for an explanation on threshold scores.
                    int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                    IdentifyResult identifyResult = Comparison.Identify(anyFinger, 0, fmds, thresholdScore, 2);
                    if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        _sender.Reset = true;
                        throw new Exception(identifyResult.ResultCode.ToString());
                    }

                    SendMessage(Action.SendMessage, "Identification resulted in the following number of matches: " + identifyResult.Indexes.Length.ToString());
                    SendMessage(Action.SendMessage, "Place your right index finger on the reader.");
                    count = 0;
                }
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, "Error:  " + ex.Message);
            }
        }
Ejemplo n.º 11
0
        private void OnCaptured(CaptureResult captureResult)
        {
            bool existio = false;

            try
            {
                if (!Clases.HuellaDigital.CheckCaptureResult(captureResult))
                {
                    return;
                }

                ////Creamos el bitmap para el PictureBox
                //foreach (Fid.Fiv fiv in captureResult.Data.Views)
                //{
                //    SendMessage(Action.SendBitmap, Clases.HuellaDigital.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                //}

                //Guardamos la variable de la huella
                res = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    Clases.HuellaDigital.Reset = true;
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                Fmd[] fmds = new Fmd[2];

                foreach (int k in Clases.HuellaDigital.Fmds.Keys)
                {
                    fmds[0] = Clases.HuellaDigital.Fmds[k];
                    int probabilidad = DPFJ_PROBABILITY_ONE * 1 / 100000;

                    IdentifyResult ideRes = Comparison.Identify(res.Data, 0, fmds, probabilidad, Clases.HuellaDigital.Fmds.Count + 1);

                    if (ideRes.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        Clases.HuellaDigital.Reset = true;
                        throw new Exception(ideRes.ResultCode.ToString());
                    }
                    if (ideRes.Indexes.Length > 0)
                    {
                        SendMessage(Action.SendOK, k.ToString());
                        existio = true;
                        break;
                    }
                }
                if (!existio)
                {
                    SendMessage(Action.SendMessage, "La huella no coincide con alguna del registro\n");
                }
            }
            catch (Exception ex)
            {
                //Mostramos un MessageBox con el mensaje de error
                SendMessage(Action.SendMessage, ex.Message);
            }
        }
Ejemplo n.º 12
0
        public Operador CompararHuella(Fmd firstF, Fmd secondF)
        {
            ///Añadimos el parametro firstF a firstFinger un objeto de tipo Fmd que sera el objeto de la huella capturada
            Fmd firstFinger = firstF;

            ///creamos el segundo objeto de tipo Fmd y le pasamos los parametros que pide el constructor de esa clase, los parametros son tomados del objeto 1
            ///se hace esto porque la propiedad bytes de un mismo objeto al ser cambiada en una variable, se cambia en todas las demas como si fuese una variable estatica
            ///y necesitamos resetear solo los bytes para poder asignarle los bytes que se encuentran en la BD al objeto 2 para compararlas
            ///solo necesitamos cambiar los bytes porque los otros parametros que pide el constructor y que el toma del objeto 1 no los vamos a necesitar para hacer la comparacion.
            Fmd secondFinger = new Fmd(firstFinger.Bytes, oHelper.Format, oHelper.Version);

            int    count    = 0;
            int    idOp     = 0;
            string codOp    = string.Empty;
            string nombreOp = string.Empty;
            string statusOP = string.Empty;

            List <Operador> ListaHuellas = transaccion.ListarHuellas();

            ///un foreach para capturar los valores de cada registro
            foreach (var item in ListaHuellas)
            {
                ///los bytes que estan registrados en la BD son de tipo Base64 que es un varchar(max), le pasamos ese string al metodo convert
                ///para que nos convierta de nuevo a bytes y se la asignamos a la variable huellaConvertida
                byte[] huellaConvertida = Convert.FromBase64String(item.Huella);

                //le asignamos los bytes de huellaConvertida que representan los bytes que estan en la BD a la propiedad Bytes del objeto secondFinger para asi poder hacer la comparacion con el obj 1 que es la huella capturada
                secondFinger.Bytes = huellaConvertida;

                ///Una vez listo los 2 objetos a comparar se lo mandamos al metodo Compare de la clase Comparision, nos devolvera un objeto de tipo CompareResult
                ///Este objeto compareResult tendra una propiedad que se llama Score que es el puntaje que necesitaremos para ver si ambas huellas tienen similitud
                CompareResult compareResult = Comparison.Compare(firstFinger, 0, secondFinger, 0);

                //preguntamos si el Score es menor a la operacion establecida en el if, si el resultado es true entonces ambas huellas tienen similitud
                if (compareResult.Score < (PROBABILITY_ONE / 100000))
                {
                    count++;
                    idOp     = item.IdOperador;
                    codOp    = item.CodOperador;
                    nombreOp = item.Nombre;
                    statusOP = item.Status;
                }
            }

            Operador operadorEncontrado = new Operador();

            if (count > 0)
            {
                operadorEncontrado             = new Operador();
                operadorEncontrado.IdOperador  = idOp;
                operadorEncontrado.CodOperador = codOp;
                operadorEncontrado.Nombre      = nombreOp;
                operadorEncontrado.Status      = statusOP;
            }

            return(operadorEncontrado);
        }
Ejemplo n.º 13
0
 private void Reset()
 {
     tbName.Text     = "";
     pressCount      = 0;
     pb1.Image       = null; pb2.Image = null; pb3.Image = null; pb4.Image = null;
     fmd1            = null;
     btnSave.Enabled = false;
     listPreRegFMDs.Clear();
 }
Ejemplo n.º 14
0
 private void enrollment_OnEnroll(EnrollmentControl enrollmentControl, DataResult <Fmd> enrollmentResult, int fingerPosition)
 {
     if (enrollmentResult != null && enrollmentResult.Data != null)
     {
         Fmd    datos  = enrollmentResult.Data;
         string cadena = Fmd.SerializeXml(datos);
         enviar(cadena);
         this.Close();
     }
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult))
                {
                    return;
                }

                SendMessage(Action.SendMessage, oHelper.Mensaje2);

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(resultConversion.ResultCode.ToString());
                }

                if (count == 0)
                {
                    firstFinger = resultConversion.Data;

                    OperadorEncontrado = funciones.CompararHuella(firstFinger, secondFinger);

                    if (OperadorEncontrado.IdOperador != 0)
                    {
                        SendMessage(Action.SendMessage, "Huella coincide con operador " + OperadorEncontrado.Nombre + " y su status es " + OperadorEncontrado.Status);
                        SendMessage(Action.SendMessage, oHelper.Mensaje1);
                    }

                    else
                    {
                        SendMessage(Action.SendMessage, oHelper.Mensaje5);
                        SendMessage(Action.SendMessage, oHelper.Mensaje1);
                    }

                    count = 0;
                }
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, oHelper.Error + ex.Message);
            }

            ///si el lector es desconectado con la ventana de verification abierta, mandamos a cerrarla automaticamente
            ///para llamar al evento Verification_Closed y que se cargue el load del main para que salga el mensajeBox de lector
            ///desconectado (Reintentar/Salir)
            if (captureResult.ResultCode == Constants.ResultCode.DP_DEVICE_FAILURE)
            {
                Thread t = new Thread(cerrar);
                t.Start();
            }
        }
Ejemplo n.º 16
0
        public void OnCaptured(CaptureResult captureResult)
        {
            this.picBoxToCap     = picBoxFingerPrint;
            this.fingerToCapture = 0;
            count++;
            lblCount.Invoke(new Action(() => { lblCount.Text = count.ToString(); }));
            DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);

            if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                if (CurrentReader != null)
                {
                    CurrentReader.Dispose();
                    CurrentReader = null;
                }

                MessageBox.Show("Error:  " + captureResult.ResultCode);
            }
            if (captureResult.Data != null)
            {
                foreach (Fid.Fiv fiv in captureResult.Data.Views)
                {
                    picBoxFingerPrint.Image    = CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height);
                    picBoxFingerPrint.SizeMode = PictureBoxSizeMode.Zoom;
                }
            }
            preenrollmentFmds.Add(resultConversion.Data);
            if (count >= 4)
            {
                resultEnrollment = Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preenrollmentFmds);

                TempFingerPrint = Fmd.SerializeXml(resultConversion.Data);

                resultEnrollment = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preenrollmentFmds);

                if (resultEnrollment.ResultCode == Constants.ResultCode.DP_SUCCESS)
                {
                    FileStream fs = new System.IO.FileStream(@"..\..\Pictures\right.bmp", FileMode.Open, FileAccess.Read);
                    picRigithWrong.Invoke(new Action(() => { picRigithWrong.Image = Image.FromStream(fs); }));
                    picRigithWrong.SizeMode = PictureBoxSizeMode.Zoom;
                    //preenrollmentFmds.Clear();
                    //count = 0;
                    MessageBox.Show("An enrollment was successfully created.");
                    return;
                }
                else if (resultEnrollment.ResultCode == Constants.ResultCode.DP_ENROLLMENT_INVALID_SET)
                {
                    MessageBox.Show("Enrollment was unsuccessful.  Please try again.");
                    preenrollmentFmds.Clear();
                    count = 0;
                    return;
                }
            }
        }
Ejemplo n.º 17
0
        private void Enrollpage_On_Enroll(DPCtlXUru.EnrollmentXControl enrollmentControl, XFmdResult result, int fingerPosition)
        {
            // Helper.Fmds.Add(fingerPosition, result.Fmd.Fmd);//Helper.Source.Add(result.Fmd.Fmd.Bytes);
            var fmdxml = Fmd.SerializeXml(result.Fmd.Fmd);
            var main   = ResourcesBase.GetMainWindowViewModel();

            Pegawai.Enrollment = fmdxml;
            var res = main.PegawaiCollection.Updated(Pegawai);

            SendMessage(ActionMessage.SendMessage, "Enroll Complete");
        }
Ejemplo n.º 18
0
        public static void updateFMDUserIDList(Fmd fmd1, Fmd fmd2, String userid)
        {
            Array.Resize(ref allUserNames, (allUserNames.Length) + 1);
            allUserNames[(allUserNames.Length) - 1] = userid;

            Array.Resize(ref allDBFmd1s, (allDBFmd1s.Length) + 1);
            allDBFmd1s[(allDBFmd1s.Length) - 1] = fmd1;

            Array.Resize(ref allDBFmd2s, (allDBFmd2s.Length) + 1);
            allDBFmd2s[(allDBFmd2s.Length) - 1] = fmd2;
        }
Ejemplo n.º 19
0
        private void button1_Click(object sender, EventArgs e)
        {
            MySqlConnection con = null;
            Boolean         got = false;

            try
            {
                String ConString = ConfigurationManager.ConnectionStrings["biometrics.Properties.Settings.testreportConnectionString"].ConnectionString;
                con = new MySqlConnection(ConString);
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
                con.Open();

                String       query = "Select * from tblfinger";
                MySqlCommand cmd   = new MySqlCommand(query, con);
                cmd.Prepare();
                MySqlDataReader row = cmd.ExecuteReader();
                if (row.HasRows)
                {
                    while (row.Read())
                    {
                        Fmd previousFinger = Fmd.DeserializeXml(row["CustomerFinger"].ToString());

                        CompareResult compareResult = Comparison.Compare(firstFinger, 0, previousFinger, 0);
                        if (compareResult.ResultCode == Constants.ResultCode.DP_SUCCESS)
                        {
                            if ((compareResult.Score < (PROBABILITY_ONE / 100000)))
                            {
                                MessageBox.Show("Welcome TO Our Page " + row["LedgerId"].ToString());
                                got = true;
                                break;
                            }
                        }
                    }
                }
                con.Close();

                if (!got)
                {
                    lblPlaceFinger.Visible = true;
                    pbFingerprint.Image    = null;
                    MessageBox.Show("Invalid Information. Please Retry ");
                    firstFinger = null;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Fail To Create User - " + ex.Message);
                con.Close();
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// The match fingerprint.
        /// </summary>
        /// <param name="firstsFmd">
        /// The firsts fmd.
        /// </param>
        /// <param name="secondFmd">
        /// The second fmd.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool MatchFingerprint(string firstsFmd, string secondFmd)
        {
            var fmdFirsts     = Fmd.DeserializeXml(firstsFmd);
            var fmdSecond     = Fmd.DeserializeXml(secondFmd);
            var resultCompare = Comparison.Compare(fmdFirsts, 0, fmdSecond, 0);

            if (resultCompare.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                return(false);
            }

            return(resultCompare.Score < (ProbabilityOne / 100000));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult))
                {
                    return;
                }

                SendMessage(Action.SendMessage, "A finger was captured.");

                IDs.Clear();

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                SendMessage(Action.SendMessage, "Please wait while searching is done in background.");

                anyFinger = resultConversion.Data;
                Fmd[] fmdsArray = fmds.ToArray();

                foreach (Fmd fmd in fmdsArray)
                {
                    CompareResult compareResult = Comparison.Compare(anyFinger, 0, fmd, 0);
                    if (compareResult.Score < (PROBABILITY_ONE / 100000))
                    {
                        IDs.Add(fmdsDic[fmd]);
                    }
                }
                SendMessage(Action.SendMessage, IDs.Count.ToString() + " Finger Print(s) Matched.");
                SendMessage(Action.SendMessage, "Click the button below to show results or place thumb to search again.");

                if (IDs.Count > 0)
                {
                    SendMessage(Action.ShowMatchedEntry, "");
                }
                else
                {
                    SendMessage(Action.HideMatchedEntry, "");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in Identification: " + ex.Message);
            }
        }
Ejemplo n.º 22
0
 /// <summary>
 /// ClearFingerprintsbyID - finds and clears the list of FMD data for a given ID
 ///           - returns false if not found
 /// </summary>
 /// <param name="lc"></param>
 /// <returns></returns>
 public bool AddFingerprintbyID(string id, Fmd data)
 {
     foreach (BiometricData bd in biometricDataList)
     {
         if (bd.ID == id)
         {
             bd.FIDList.Add(Fmd.SerializeXml(data));
             bd.FMDs.Add(data);
             return(true);
         }
     }
     AddBiometricData(new BiometricData(id, data));
     return(false);
 }
Ejemplo n.º 23
0
        /// <summary>
        /// The on capture.
        /// </summary>
        /// <param name="captureResult">
        /// The capture result.
        /// </param>
        private void OnCapture(CaptureResult captureResult)
        {
            var resultFingerprint = new ResultFingerprint {
                Result = this.CheckCaptureResult(captureResult)
            };

            resultFingerprint.Message                 = !resultFingerprint.Result ? es_CO.BadCapture : es_CO.Captured;
            resultFingerprint.ImageFingerprints       = !resultFingerprint.Result ? null : FingerprintSerializer.GetFingerprintBitmap(captureResult.Data.Views);
            resultFingerprint.StringImageFingerprints = !resultFingerprint.Result ? null : FingerprintSerializer.GetFingerprintStringBitmap(captureResult.Data.Views);
            resultFingerprint.XmlFmd = !resultFingerprint.Result ? string.Empty : Fmd.SerializeXml(FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI).Data);
            resultFingerprint.FileFingerprintImage = !resultFingerprint.Result ? string.Empty : FingerprintSerializer.GetFingerprintFile(captureResult.Data.Views);

            this.CaptureProcessed?.Invoke(resultFingerprint);
        }
        private void DoFingerprintAuth()
        {
            Verification verificationForm    = null;
            var          mainObject          = new MainObject();
            var          readerSelectionForm = new ReaderSelection
            {
                Currentinstance = mainObject
            };

            readerSelectionForm.ShowDialog();

            if (UserExists)
            {
                //uncomment to bypass fingerprint in the absence of scanner
                //AuthenticationData.Single(d => d.Scheme == FingerprintAuthentication).Authenticated = true;
                //return;
                if (verificationForm == null)
                {
                    verificationForm = new Verification
                                       (
                        successful =>
                    {
                        successful = successful && UserRepository.LogSuccessfulEntry(verificationForm.SuccessReading, User.Email);

                        AuthenticationData.Single(d => d.Scheme == FingerprintAuthentication).Authenticated = successful;
                    }
                                       )
                    {
                        Currentinstance = mainObject
                    };
                }

                var strFmds = User.Snapshots.SelectMany(s => s.Fingerprints).Select(s => s.Fmd);
                if (strFmds.Any())
                {
                    var fmds = new List <Fmd>();
                    foreach (var strFmd in strFmds)
                    {
                        var fmd = Fmd.DeserializeXml(strFmd);
                        fmds.Add(fmd);
                    }
                    verificationForm.database = fmds;

                    verificationForm.ShowDialog();
                }
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// FindIDbyFingerprints - finds and returns the ids which contain the FMD data
        ///           - returns null if not found
        /// </summary>
        /// <param name="lc"></param>
        /// <returns></returns>
        public List <string> FindIDbyFingerprints(Fmd finger)
        {
            List <string> list = new List <string>();

            foreach (BiometricData bd in biometricDataList)
            {
                foreach (Fmd f in bd.FMDs)
                {
                    if (f == finger)
                    {
                        list.Add(bd.ID);
                        break;
                    }
                }
            }
            return(list);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult))
                {
                    return;
                }

                SendMessage(Action.SendMessage, "A finger was captured.");

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(resultConversion.ResultCode.ToString());
                }

                if (count == 0)
                {
                    firstFinger = resultConversion.Data;
                    count      += 1;
                    SendMessage(Action.SendMessage, "Now place the same or a different finger on the reader.");
                }
                else if (count == 1)
                {
                    secondFinger = resultConversion.Data;
                    CompareResult compareResult = Comparison.Compare(firstFinger, 0, secondFinger, 0);
                    if (compareResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        _sender.Reset = true;
                        throw new Exception(compareResult.ResultCode.ToString());
                    }

                    SendMessage(Action.SendMessage, "Comparison resulted in a dissimilarity score of " + compareResult.Score.ToString() + (compareResult.Score < (PROBABILITY_ONE / 100000) ? " (fingerprints matched)" : " (fingerprints did not match)"));
                    SendMessage(Action.SendMessage, "Place a finger on the reader.");
                    count = 0;
                }
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, "Error:  " + ex.Message);
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Initialize the form.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Identification_Load(object sender, System.EventArgs e)
        {
            getData();

            txtIdentify.Text = string.Empty;
            anyFinger        = null;

            if (!_sender.OpenReader())
            {
                this.Close();
            }

            if (!_sender.StartCaptureAsync(this.OnCaptured))
            {
                this.Close();
            }
        }
Ejemplo n.º 28
0
        void reader_On_Captured(CaptureResult capResult)
        {
            if (capResult.Quality == Constants.CaptureQuality.DP_QUALITY_GOOD)
            {
                DataResult <Fmd> fmdResult = FeatureExtraction.CreateFmdFromFid(capResult.Data, Constants.Formats.Fmd.DP_VERIFICATION);
                //If successfully extracted fmd then assign fmd
                if (fmdResult.ResultCode == Constants.ResultCode.DP_SUCCESS)
                {
                    fmd = fmdResult.Data;
                    // Get view bytes to create bitmap.
                    foreach (Fid.Fiv fiv in capResult.Data.Views)
                    {
                        UpdateVerifyMessage("Fingerprint Captured", CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                        break;
                    }
                }
                else
                {
                    UpdateVerifyMessage("Could not successfully create a verification FMD", null);
                }

                //Perform indentification of fmd of captured sample against enrolledFmdList
                IdentifyResult vResult = Comparison.Identify(fmd, 0, enrolledFmdList, 21474, 5);

                //If number of matches returned by IdentificationResult are greater than 0 then user is authorized
                if (vResult.ResultCode == Constants.ResultCode.DP_SUCCESS)
                {
                    if (vResult.Indexes.Length > 0)
                    {
                        UpdateVerifyMessage("User Authorized", null);
                    }
                    else
                    {
                        UpdateVerifyMessage("User Unauthorized", null);
                    }
                }
                else
                {
                    UpdateVerifyMessage("Error occured on verfication.", null);
                }
            }
            else
            {
                UpdateVerifyMessage("Please swipe finger again", null);
            }
        }
        private bool isFingerprintDataExist(Fmd fingerprint)
        {
            // See the SDK documentation for an explanation on threshold scores.
            int            thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;
            IdentifyResult identifyResult = Comparison.Identify(fingerprint, 0, adminsFingerprintData.ToArray(), thresholdScore, adminsFingerprintData.Count);

            if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                throw new Exception(identifyResult.ResultCode.ToString());
            }

            if (identifyResult.Indexes.Length > 0)
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 30
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var computerNo = tbName.Text.Trim();

            if (computerNo.Length == 0)
            {
                MessageBox.Show("Please enter Computer Number");
                return;
            }

            string xmlFMD1 = Fmd.SerializeXml(fmd1);

            string saveFmdScript = "UPDATE Prisoners SET FMD1='" + xmlFMD1 + "' WHERE PrisonerId = (SELECT PrisonerId FROM Admissions WHERE AdmissionId = " + computerNo + ")";

            // Save user and his relative FMD into database
            int count = HelperFunctions.ConnectDBnExecuteScript(saveFmdScript);

            if (count == 1)
            {
                PostFingerprintImage(pb3.Image, computerNo);
                MessageBox.Show("Successfully enrolled fingerprint of Computer Number : " + computerNo);
                Reset();
            }
            else
            {
                MessageBox.Show("Computer Number " + computerNo + " NOT found!");
            }

            //if (leftIndex == null || rightIndex == null) { MessageBox.Show("Fingerprint enrollment incomplete."); return; }
            //try
            //{
            //    identification.AddUser(new User(tbName.Text, leftIndex, rightIndex));
            //}
            //catch (ArgumentException ex)
            //{
            //    MessageBox.Show("User ID already taken.  Please enter a different ID.");
            //    return;
            //}
            //this.DialogResult = System.Windows.Forms.DialogResult.OK;
            //reader.Dispose();
            //this.Close();
            //return;
        }