private FatFileLocation FindEntry(Comparison compare, uint startCluster) { uint activeSector = ((startCluster - RootCluster) * SectorsPerCluster) + DataSector; if (startCluster == 0) { activeSector = (FatType == FatType.FAT32) ? GetSectorByCluster(RootCluster) : RootSector; } byte[] aData = new byte[BytePerSector * SectorsPerCluster]; this.IDevice.Read(activeSector, SectorsPerCluster, aData); for (uint index = 0; index < EntriesPerSector * SectorsPerCluster; index++) { int offset = (int)(index * (int)Entry.EntrySize); if (compare.Compare(aData, offset, FatType)) { FatFileAttributes attribute = (FatFileAttributes)aData[offset + (int)Entry.FileAttributes]; return(new FatFileLocation( GetClusterEntry(aData, index, FatType), activeSector, index, (attribute & FatFileAttributes.SubDirectory) != 0, BitConverter.ToInt32(aData, offset + (int)Entry.FileSize))); } if (aData[(int)Entry.DOSName + offset] == (int)FileNameAttribute.LastEntry) { break; } } return(null); }
internal static PhpValue FindExtreme(IEnumerable <PhpValue> array, bool maximum) { Debug.Assert(array != null); PhpValue ex; var enumerator = array.GetEnumerator(); if (enumerator.MoveNext()) { ex = enumerator.Current.GetValue(); int fact = maximum ? 1 : -1; while (enumerator.MoveNext()) { if (Comparison.Compare(enumerator.Current, ex) * fact > 0) { ex = enumerator.Current.GetValue(); } } } else { ex = PhpValue.Null; } enumerator.Dispose(); // return(ex); }
public static int version_compare(string version1, string version2) { string[] v1 = VersionToArray(version1); string[] v2 = VersionToArray(version2); int result; for (int i = 0; i < Math.Max(v1.Length, v2.Length); i++) { string item1 = (i < v1.Length) ? v1[i] : " "; string item2 = (i < v2.Length) ? v2[i] : " "; if (char.IsDigit(item1[0]) && char.IsDigit(item2[0])) { result = Comparison.Compare(Core.Convert.StringToLongInteger(item1), Core.Convert.StringToLongInteger(item2)); } else { result = CompareParts(char.IsDigit(item1[0]) ? "#" : item1, char.IsDigit(item2[0]) ? "#" : item2); } if (result != 0) { return(result); } } return(0); }
public int Get_DP_Template(ref DataSet DataSet, int TemplateNo, byte[] bytPreviousFingerTemplate, byte[] bytCurrentFingeTemplate, ref byte[] bytEnrollmentFingerTemplate) { int intReturnCode = 0; DPUruNet.Fmd fmdPreviousFingerTemplate = DPUruNet.Importer.ImportFmd(bytPreviousFingerTemplate, Constants.Formats.Fmd.ANSI, Constants.Formats.Fmd.ANSI).Data; DPUruNet.Fmd fmdCurrentFingerTemplate = DPUruNet.Importer.ImportFmd(bytCurrentFingeTemplate, Constants.Formats.Fmd.ANSI, Constants.Formats.Fmd.ANSI).Data; //Compare Template CompareResult cmrCompareResult = Comparison.Compare(fmdCurrentFingerTemplate, 0, fmdPreviousFingerTemplate, 0); if (cmrCompareResult.ResultCode == Constants.ResultCode.DP_SUCCESS) { int PROBABILITY_ONE = 0x7fffffff; int intFarRequested = PROBABILITY_ONE / 10000; if (cmrCompareResult.Score < intFarRequested) { if (TemplateNo == 4) { List <Fmd> preEnrollmentFmds = new List <Fmd>(); //Add Current Template preEnrollmentFmds.Add(fmdCurrentFingerTemplate); for (int intRow = 0; intRow < DataSet.Tables["Template"].Rows.Count; intRow++) { DPUruNet.Fmd fmdFingerTemplate = DPUruNet.Importer.ImportFmd((byte[])DataSet.Tables["Template"].Rows[intRow]["FINGER_TEMPLATE"], Constants.Formats.Fmd.ANSI, Constants.Formats.Fmd.ANSI).Data; preEnrollmentFmds.Add(fmdFingerTemplate); } DataResult <Fmd> drResultEnrollment = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preEnrollmentFmds); if (drResultEnrollment.ResultCode == Constants.ResultCode.DP_SUCCESS) { bytEnrollmentFingerTemplate = drResultEnrollment.Data.Bytes; } else { intReturnCode = 2; } } else { bytEnrollmentFingerTemplate = bytCurrentFingeTemplate; } } else { intReturnCode = 1; } } else { intReturnCode = 1; } return(intReturnCode); }
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); }
public override void OnNodeEnable() { if (Comparison.Compare()) { GoToNode(TruePort); } else { GoToNode(FalsePort); } }
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(); } }
/// <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)); }
/// <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); } }
/// <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); } }
public int Match(FingerTemplate template, IEnumerable <FingerTemplate> candidates, out List <FingerTemplate> matches) { // extract FMD from FID TemplateDP templateDP = template as TemplateDP; matches = new List <FingerTemplate>(); foreach (var candidate in candidates.OfType <TemplateDP>()) { var identifyResult = Comparison.Compare(templateDP.fmd, 0, candidate.fmd, 0); if (identifyResult.ResultCode == Constants.ResultCode.DP_SUCCESS) { if (identifyResult.Score < DP_THRESHOLD) { matches.Add(candidate); } } } return(matches.Count); }
/// <summary> /// Open the reader and capture two fingers to compare. /// </summary> private void VerifyThread() { Constants.ResultCode result = Constants.ResultCode.DP_DEVICE_FAILURE; result = currentinstance.CurrentReader.Open(Constants.CapturePriority.DP_PRIORITY_COOPERATIVE); if (result != Constants.ResultCode.DP_SUCCESS) { MessageBox.Show("Error: " + result); if (currentinstance.CurrentReader != null) { currentinstance.CurrentReader.Dispose(); currentinstance.CurrentReader = null; } return; } Fmd fmd1 = null; // Fmd fmd2 = null; SendMessage("Place a finger on the reader."); int count = 0; while (!reset) { Fid fid = null; if (!currentinstance.CaptureFinger(ref fid)) { break; } if (fid == null) { continue; } SendMessage("A finger was captured."); DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI); if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS) { break; } /* if (count == 0) * { * fmd1 = resultConversion.Data; * count += 1; * SendMessage("Now place the same or a different finger on the reader."); * } * else if (count == 1) * { * fmd2 = resultConversion.Data; * CompareResult compareResult = Comparison.Compare(fmd1, 0, fmd2, 0); * * if (compareResult.ResultCode != Constants.ResultCode.DP_SUCCESS) * { * break; * } * * SendMessage("Comparison resulted in a dissimilarity score of " + compareResult.Score.ToString() + (compareResult.Score < (PROBABILITY_ONE/100000) ? " (fingerprints matched)" : " (fingerprints did not match)")); * SendMessage("Place a finger on the reader."); * count = 0; * }*/ fmd1 = resultConversion.Data; bool pass_threshold = false; foreach (Fmd fd in database) { CompareResult compareResult = Comparison.Compare(fmd1, 0, fd, 0); if (compareResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { break; } pass_threshold = compareResult.Score < (PROBABILITY_ONE / 100000); SendMessage("Comparison resulted in a dissimilarity score of " + compareResult.Score.ToString() + (pass_threshold ? " (fingerprints matched)" : " (fingerprints did not match)")); //SendMessage("Place a finger on the reader."); if (pass_threshold) { MessageBox.Show("Verification Successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); break; } } if (!pass_threshold) { MessageBox.Show("Verification Failed!!!", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (currentinstance.CurrentReader != null) { currentinstance.CurrentReader.Dispose(); } }
private void OnCaptured(CaptureResult captureResult) { try { // Check capture quality and throw an error if bad. if (!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) { Reset = true; throw new Exception(captureResult.ResultCode.ToString()); } currentFinger = resultConversion.Data; var fmds = new List <Fmd>(); var students = _db.Students.ToList(); //get string version of the current fmd //Fmd fmd = Fmd.DeserializeXml(student.FingerPrint); foreach (var student in students) { if (student.FingerPrint == null) { continue; } Fmd fmd = Fmd.DeserializeXml(student.FingerPrint); CompareResult compareResult = Comparison.Compare(currentFinger, 0, fmd, 0); if (compareResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { Reset = true; throw new Exception(compareResult.ResultCode.ToString()); } else { if (compareResult.Score < (DPFJ_PROBABILITY_ONE / 100000)) { if (captureResult.Data != null) { foreach (Fid.Fiv fiv in captureResult.Data.Views) { pictureBox.Image = CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height); pictureBox.SizeMode = PictureBoxSizeMode.Zoom; } } FileStream fs = new System.IO.FileStream(@"..\..\Pictures\right.bmp", FileMode.Open, FileAccess.Read); lblrstLastName.Invoke(new Action(() => { lblrstLastName.Text = student.LastName; })); lblrstFirstName.Invoke(new Action(() => { lblrstFirstName.Text = student.FirstName; })); lblrstMiddleName.Invoke(new Action(() => { lblrstMiddleName.Text = student.MiddleName; })); lblrstMatricNo.Invoke(new Action(() => { lblrstMatricNo.Text = student.MatricNo; })); lblrstEmail.Invoke(new Action(() => { lblrstEmail.Text = student.Email; })); lblrstPhone.Invoke(new Action(() => { lblrstPhone.Text = student.Phone; })); cmbCollege.Invoke(new Action(() => { cmbCollege.SelectedValue = student.CollegeId; })); cmbProgramme.Invoke(new Action(() => { cmbProgramme.SelectedValue = student.ProgrammeId; })); cmbLevel.Invoke(new Action(() => { cmbLevel.SelectedValue = student.LevelId; })); //pictureBox.Invoke(new Action(() => { pictureBox1.Image = Image.FromFile(@"..\..\Pictures\right.bmp"); })); pictureBox1.Invoke(new Action(() => { pictureBox1.Image = Image.FromStream(fs); })); pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; fs.Close(); return; } else { //MessageBox.Show("The Student does not exist in the database"); } } } ; //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."); //} } catch (Exception ex) { // Send error message, then close form //SendMessage(Action.SendMessage, "Error: " + ex.Message); } }
/// <summary> /// Open the reader and capture two fingers to compare. /// </summary> private void VerifyThread() { var result = Constants.ResultCode.DP_DEVICE_FAILURE; result = Currentinstance.CurrentReader.Open(Constants.CapturePriority.DP_PRIORITY_COOPERATIVE); if (result != Constants.ResultCode.DP_SUCCESS) { MessageBox.Show("Error: " + result); if (Currentinstance.CurrentReader != null) { Currentinstance.CurrentReader.Dispose(); Currentinstance.CurrentReader = null; } return; } Fmd fmd1 = null; // Fmd fmd2 = null; SendMessage("Place a finger on the reader."); while (!reset) { Fid fid = null; if (!Currentinstance.CaptureFinger(ref fid)) { break; } if (fid == null) { continue; } SendMessage("A finger was captured."); var resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI); if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS) { break; } /* if (count == 0) * { * fmd1 = resultConversion.Data; * count += 1; * SendMessage("Now place the same or a different finger on the reader."); * } * else if (count == 1) * { * fmd2 = resultConversion.Data; * CompareResult compareResult = Comparison.Compare(fmd1, 0, fmd2, 0); * * if (compareResult.ResultCode != Constants.ResultCode.DP_SUCCESS) * { * break; * } * * SendMessage("Comparison resulted in a dissimilarity score of " + compareResult.Score.ToString() + (compareResult.Score < (PROBABILITY_ONE/100000) ? " (fingerprints matched)" : " (fingerprints did not match)")); * SendMessage("Place a finger on the reader."); * count = 0; * }*/ fmd1 = resultConversion.Data; var pass_threshold = false; foreach (var fd in database) { var compareResult = Comparison.Compare(fmd1, 0, fd, 0); if (compareResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { break; } pass_threshold = compareResult.Score < (PROBABILITY_ONE / 100000); SendMessage("Comparison resulted in a dissimilarity score of " + compareResult.Score.ToString() + (pass_threshold ? " (fingerprints matched)" : " (fingerprints did not match)")); //SendMessage("Place a finger on the reader."); if (pass_threshold) { break; } } if (Currentinstance.CurrentReader != null) { Currentinstance.CurrentReader.Dispose(); Currentinstance.CurrentReader = null; } FormClosed += (o, e) => { if (pass_threshold) { SuccessReading = Fmd.SerializeXml(fmd1); } OnComplete(pass_threshold); }; verifyThreadHandle.Abort(); } if (Currentinstance.CurrentReader != null) { Currentinstance.CurrentReader.Dispose(); Currentinstance.CurrentReader = null; } }
private void IdentifyThread() { while (!reset) { Fid fid = null; if (!CaptureFinger(ref fid)) { //break; } if (objReader == null) { objReader = objDeviceReader.IndexDevice(); objDeviceReader.InitializeDevice(ref objReader); } if (fid == null) { continue; } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI); if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS) { //break; if (objReader != null) { objReader.Dispose(); objReader = null; } return; } int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000; Fmd aux = resultConversion.Data; Fmd temp; foreach (Clases.Persona item in listPersons) { temp = Fmd.DeserializeXml(item.huella); CompareResult identifyResult = Comparison.Compare(aux, 0, temp, 0); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { break; } if (identifyResult.Score < thresholdScore) { SendMessage("Identificado"); MessageBox.Show("Identificado"); Thread.Sleep(3000); SendMessage("Buscando..."); break; } } } if (objReader != null) { objReader.Dispose(); } }
private void IdentifyThread() { while (!reset) { Fid fid = null; if (!CaptureFinger(ref fid)) { //break; } if (objReader == null) { objReader = objDeviceReader.IndexDevice(); objDeviceReader.InitializeDevice(ref objReader); } if (fid == null) { continue; } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI); if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS) { //break; if (objReader != null) { objReader.Dispose(); objReader = null; } return; } int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000; Fmd aux = resultConversion.Data; Fmd temp; foreach (Clases.Persona item in listPersons) { try { temp = Fmd.DeserializeXml(item.huella); CompareResult identifyResult = Comparison.Compare(aux, 0, temp, 0); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { break; } var responseString = ""; if (identifyResult.Score < thresholdScore) { //guardar la asistencia en la base de datos try { using (var client = new WebClient()) { DateTime checada = DateTime.Now; var values = new NameValueCollection(); values["cuenta"] = item.id; values["evento"] = _evento; values["checada"] = checada.ToString("yyyy-MM-dd H:mm:ss"); var response = client.UploadValues("http://facite.uas.edu.mx/agenda/registrar_checada.php", values); responseString = Encoding.Default.GetString(response); } } catch (Exception err) { MessageBox.Show(err.Message); } SendMessage(responseString, item.Nombre, "Se registró a las " + DateTime.Now.ToShortTimeString(), "", "", ""); Thread.Sleep(3000); SendMessage("Coloque el dedo en el checador...", "", "", "", "", ""); menuPrincipal.Dispatcher.BeginInvoke(new Action(delegate() { menuPrincipal.lbl_fechas.Content = ""; menuPrincipal.lbl_resto.Content = ""; })); break; } else { //SendMessage("No se encuentra registrada la huella", "", "", "","",""); // Thread.Sleep(2000); SendMessage("Coloque el dedo en el checador...", "", "", "", "", ""); menuPrincipal.Dispatcher.BeginInvoke(new Action(delegate() { menuPrincipal.lbl_fechas.Content = ""; menuPrincipal.lbl_resto.Content = ""; })); //break; } } catch (Exception error) { MessageBox.Show(error.Message); } } } if (objReader != null) { objReader.Dispose(); } }
/// <summary> /// Finger print verification /// </summary> private void FingerprintVerifcation1() { this.Cursor = Cursors.WaitCursor; try { string identification = string.Empty; string scores = string.Empty; string folderPath = this.txtDirectory.Text; //delcare the folder containing fingerprint samples string fileName = "matchScores.txt"; //Convert the uploaded fingerprint to raw byte[] //Create FMD of the uploaded fingerprint from Raw DataResult <Fmd> fmd = FeatureExtraction.CreateFmdFromRaw(ConvertToRaw(this.fingerprint), 0, 0, fingerprint.Width, fingerprint.Height, (int)this.fingerprint.HorizontalResolution, Constants.Formats.Fmd.ISO); string[] directories = Directory.GetDirectories(folderPath); if (directories.Length > 0) { foreach (string subDirPath in directories) { scores = string.Empty; //Convert the fingerprint samples to raw byte[] //Create FMD of the fingerprint samples from Raw IEnumerable <Fmd> fingerPrintFMD = CreateFMD(subDirPath); //Compare the uploaded fingerprint with fingerprint samples foreach (Fmd sampleFMD in fingerPrintFMD) { if (sampleFMD == null) { int matchScore = Int32.MaxValue; scores += matchScore.ToString() + "; "; continue; } else { CompareResult rst = Comparison.Compare(fmd.Data, 0, sampleFMD, 0); if (rst.Score == 0) { identification += Path.GetFileName(subDirPath) + " - "; } scores += rst.Score.ToString() + "; "; } } //Store match scores in a string array scores = scores.Substring(0, scores.Length - 2); string[] matchScoreArr = scores.Split(';'); if (File.Exists(subDirPath + "\\" + fileName)) { File.Delete(subDirPath + "\\" + fileName); } //Create data table containing file name and match scores DataTable dtScores = new DataTable(); dtScores.Columns.Add("FileName"); dtScores.Columns.Add("MatchScores"); for (int i = 0; i < Directory.GetFiles(subDirPath).Length; i++) { DataRow dr = dtScores.NewRow(); dr["FileName"] = Directory.GetFiles(subDirPath)[i]; dr["MatchScores"] = matchScoreArr[i]; dtScores.Rows.Add(dr); } //write match scores into a file CreateFile(dtScores, subDirPath + "\\" + fileName); } } else { //Convert the fingerprint samples to raw byte[] //Create FMD of the fingerprint samples from Raw IEnumerable <Fmd> fingerPrintFMD = CreateFMD(folderPath); //Compare the uploaded fingerprint with fingerprint samples foreach (Fmd sampleFMD in fingerPrintFMD) { if (sampleFMD == null) { int matchScore = Int32.MaxValue; scores += matchScore.ToString() + "; "; continue; } else { CompareResult rst = Comparison.Compare(fmd.Data, 0, sampleFMD, 0); //scores += rst.Score.ToString() + "; "; if (rst.Score == 0) { identification += Path.GetFileName(folderPath) + " - "; } scores += rst.Score.ToString() + "; "; } } //Store match scores in a string array scores = scores.Substring(0, scores.Length - 2); string[] matchScoreArr = scores.Split(';'); if (File.Exists(folderPath + "\\" + fileName)) { File.Delete(folderPath + "\\" + fileName); } //Create data table containing file name and match scores DataTable dtScores = new DataTable(); dtScores.Columns.Add("FileName"); dtScores.Columns.Add("MatchScores"); for (int i = 0; i < Directory.GetFiles(folderPath).Length; i++) { DataRow dr = dtScores.NewRow(); dr["FileName"] = Directory.GetFiles(folderPath)[i]; dr["MatchScores"] = matchScoreArr[i]; dtScores.Rows.Add(dr); } //write match scores into a file CreateFile(dtScores, folderPath + "\\" + fileName); } if (identification.Trim().Equals(string.Empty)) { MessageBox.Show("No match found!", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { identification = identification.Substring(0, identification.Length - 2); MessageBox.Show("Identified candidates: " + identification.Trim(), "Result", MessageBoxButtons.OK, MessageBoxIcon.Information); } MessageBox.Show("Verification done! A text file with match scores has been created in every folder containing fingerprint samples", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { throw; } this.Cursor = Cursors.Arrow; }
private void OnCaptured(CaptureResult result) { frmEncontrarDispositivo n = new frmEncontrarDispositivo(); //if (n.conectado==false) //{ // DialogResult dialogoerror = globales.MessageBoxError("Ocurrio un error, no se detecta dispositivo", "Verificar", globales.menuPrincipal); // return; // dispo.Text = "DISPOSITIVO NO CONECTADO"; //} DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(result.Data, Constants.Formats.Fmd.ANSI); if (result.ResultCode != Constants.ResultCode.DP_SUCCESS) { //throw new Exception(result.ResultCode.ToString()); } Fmd capturado = resultConversion.Data; try { string hexa = ByteArrayToString(capturado.Bytes); } catch { CheckForIllegalCrossThreadCalls = false; dispo.Text = "DISPOSITIVO NO CONECTADO"; return; } // string query = $"select jpp,num,huella from nominas_catalogos.maestro where huella is not null order by jpp,num"; string query = "select jpp,num,huella from nominas_catalogos.maestro where huella is not null and huella <>'' order by jpp,num"; List <Dictionary <string, object> > resultado = globales.consulta(query); if (resultado.Count <= 0) { return; } string caaaa = Fmd.SerializeXml(capturado); Fmd dese = Fmd.DeserializeXml(caaaa); bool encontrado = true; foreach (Dictionary <string, object> item in resultado) { string xmlStr = Convert.ToString(item["huella"]); XmlDocument xml = new XmlDocument(); xml.LoadXml(xmlStr); Fmd fmd = Fmd.DeserializeXml(xmlStr); Fmd[] fmds = new Fmd[1]; fmds[0] = fmd; // fmds[1] = capturado; int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000; CompareResult resultadoAux = Comparison.Compare(capturado, 0, fmd, 0); IdentifyResult identifyResult = Comparison.Identify(capturado, 0, fmds, thresholdScore, 2); if (resultadoAux.Score == 0) { realizarMensaje(tipo_mensaje.success, $"{item["jpp"]} encontrado"); query = $"select * from nominas_catalogos.maestro where huella is not null and jpp = '{item["jpp"]}' and num = {item["num"]} order by jpp,num"; resultado = globales.consulta(query); if (resultado.Count != 0) { huellita = true; rellenar(resultado[0]); } encontrado = true; break; } else { encontrado = false; } if (resultadoAux.ResultCode != Constants.ResultCode.DP_SUCCESS) { realizarMensaje(tipo_mensaje.exclamation, "UPS, NO SE ENCUENTRA LA HUELLA EN LA BASE"); encontrado = true; return; } } if (!encontrado) { realizarMensaje(tipo_mensaje.exclamation, "UPS, NO SE ENCUENTRA LA HUELLA EN LA BASE"); } }
private void IdentifyThread() { while (!reset) { Fid fid = null; if (!CaptureFinger(ref fid)) { //break; } if (objReader == null) { objReader = objDeviceReader.IndexDevice(); objDeviceReader.InitializeDevice(ref objReader); } if (fid == null) { continue; } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI); if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS) { //break; if (objReader != null) { objReader.Dispose(); objReader = null; } return; } int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000; Fmd aux = resultConversion.Data; Fmd temp; foreach (Clases.Persona item in listPersons) { try { temp = Fmd.DeserializeXml(item.huella); CompareResult identifyResult = Comparison.Compare(aux, 0, temp, 0); if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { break; } if (identifyResult.Score < thresholdScore) { List <Datos.membresia> mem = new Negocios.Nmembresia().ListarMembresia(item.id); //guardar la asistencia en la base de datos try { //insertamos en la base de datos string cs = ConfigurationManager.ConnectionStrings["saffron.GYM.GYM2"].ConnectionString; SqlConnection conexion = new SqlConnection(cs); conexion.Open(); SqlCommand query = new SqlCommand("INSERT INTO GYM.asistencias VALUES (" + item.id + ", GETDATE())", conexion); query.ExecuteNonQuery(); conexion.Close(); } catch (Exception err) { MessageBox.Show(err.Message); } if (mem.Count > 0) { string membresia = ""; DateTime fecha_i = DateTime.Now; DateTime fecha_f = DateTime.Now; foreach (var m in mem) { //sacamos el tipo de membresia switch (m.tipo_membresia) { case "G": membresia = "Gimnasio"; break; case "Z": membresia = "Zumba"; break; case "C": membresia = "Crossfit"; break; } //sacamos la fecha inicial } // Difference in days, hours, and minutes. TimeSpan ts = fecha_f - DateTime.Now; // Difference in days. int differenceInDays = ts.Days; SendMessage("Cliente identificado: ", item.Nombre, membresia, fecha_i.ToShortDateString(), fecha_f.ToShortDateString(), differenceInDays.ToString()); } else { SendMessage("Cliente identificado: ", item.Nombre, "Sin Membresia Activa", "", "", ""); } Thread.Sleep(10000); SendMessage("Coloque el dedo en el checador...", "", "", "", "", ""); menuPrincipal.Dispatcher.BeginInvoke(new Action(delegate() { menuPrincipal.lblMembresia.Content = ""; menuPrincipal.lbl_inicio.Content = ""; menuPrincipal.lbl_fin.Content = ""; menuPrincipal.lbl_resto.Content = ""; })); break; } /*else * { * SendMessage("No se encuentra registrada la huella capturada", "", "", "","",""); * Thread.Sleep(2000); * SendMessage("Coloque el dedo en el checador...", "", "", "", "",""); * break; * }*/ } catch (Exception error) { MessageBox.Show(error.Message); } } } if (objReader != null) { objReader.Dispose(); } }
public static bool VectorCompare(Vector3D a, Vector3D b, Comparison <double> comparitor) { return(comparitor.Compare(a.X, b.X) && comparitor.Compare(a.Y, b.Y) && comparitor.Compare(a.Z, b.Z)); }
/// <summary> /// /// </summary> /// <param name="Userid"></param> /// <param name="Timeout"></param> /// <returns>Returns dissimilarity score. Higher numbers are less of a match. 0 is a perfect match. -1 is an error</returns> public int VerifyFingerprint(string Userid, int Timeout, BiometricDataManager BioDataManager) { if (Reader.Open(Constants.CapturePriority.DP_PRIORITY_EXCLUSIVE) != Constants.ResultCode.DP_SUCCESS) { Reader.Dispose(); throw new Exception("Biometric Scanner Failed\r\nto Open for Verification"); } try { GetStatus(); SetLabelText(labelMessage, LanguageTranslation.SCAN_ENROLLED_FINGERPRINT); CaptureResult Result = Reader.Capture(Constants.Formats.Fid.ANSI, Constants.CaptureProcessing.DP_IMG_PROC_DEFAULT, Timeout, Reader.Capabilities.Resolutions.First <int>()); if (!CheckCaptureResult(Result)) { Reader.Dispose(); return(-1); } else if (Result.Quality == Constants.CaptureQuality.DP_QUALITY_TIMED_OUT) { Reader.Dispose(); return(-2); } DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(Result.Data, Constants.Formats.Fmd.ANSI); if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS) { Reader.Dispose(); throw new Exception("Biometric Scanner Verify\r\nResultConversion Error: " + resultConversion.ResultCode.ToString()); } CompareResult compareResult; foreach (Fmd data in BioDataManager.FindFingerprint(Userid)) { compareResult = Comparison.Compare(resultConversion.Data, 0, data, 0); if (compareResult.ResultCode != Constants.ResultCode.DP_SUCCESS) { Reader.Dispose(); throw new Exception("Biometric Scanner Verify\r\nResultCode Error: " + compareResult.ResultCode.ToString()); } //Analyze the score of the fingerprint to see if it is good enough to call a match if (AnalyzeFingerprintVerificationScore(compareResult.Score, Program.BIOMETRIC_FALSE_POSITIVE_RATIO)) { Reader.Dispose(); return(0); } } Reader.Dispose(); return(-3); } catch (Exception ex) { throw ex; } finally { if (Reader != null) { Reader.Dispose(); } } }
/// <summary> /// Compares two "PHP-standardized" version number strings. /// </summary> public static int version_compare(string version1, string version2) { string[] array1 = VersionToArray(version1); string[] array2 = VersionToArray(version2); for (int index = 0; index < Math.Max(array1.Length, array2.Length); ++index) { string str1 = index < array1.Length ? array1[index] : " "; string str2 = index < array2.Length ? array2[index] : " "; int num = !char.IsDigit(str1[0]) || !char.IsDigit(str2[0]) ? CompareParts(char.IsDigit(str1[0]) ? "#" : str1, char.IsDigit(str2[0]) ? "#" : str2) : Comparison.Compare(Pchp.Core.Convert.StringToLongInteger(str1), Pchp.Core.Convert.StringToLongInteger(str2)); if (num != 0) { return(num); } } return(0); }