public AFISVerificationResult VerifyUser_New(long userId, List <Fingerprint> fingerprints, int threshold) { AFISVerificationResult result = new AFISVerificationResult(); if (!_userList_new.ContainsKey(userId)) { throw new Exception("USER NOT REGISTERED"); } LocalUser user = _userList_new[userId]; List <Fingerprint> userFingerprints = user.Fingerprints; double dMaxScore = 0.0; //for (int i = 0; i < userFingerprints.Count; i++) Parallel.ForEach(userFingerprints, (fgn, loopout) => { for (int j = 0; j < fingerprints.Count; j++) { double dScore = new Matcher().Match(fgn.Template, fingerprints[j].Template); //double dScore = new Matcher().Match(userFingerprints[i].Template, fingerprints[j].Template); if (dScore > threshold && dScore > dMaxScore) { dMaxScore = dScore; result.Score = dMaxScore; result.Hit = true; //return result; loopout.Stop(); } } }); return(result); }
public AFISVerificationResult IdentifyUser(long userId, List <Fingerprint> fingerprints, int threshold) { AFISVerificationResult result = new AFISVerificationResult(); //if (!_userList.ContainsKey(userId)) //{ // throw new Exception("USER NOT REGISTERED"); //} LocalUser user = _userList[userId]; List <Fingerprint> userFingerprints = user.Fingerprints; double dMaxScore = 0.0; for (int i = 0; i < userFingerprints.Count; i++) { for (int j = 0; j < fingerprints.Count; j++) { double dScore = new Matcher().Match(userFingerprints[i].Template, fingerprints[j].Template); if (dScore > threshold && dScore > dMaxScore) { dMaxScore = dScore; result.Score = dMaxScore; result.Hit = true; return(result); } } } return(result); }
public AFISVerificationResult muserpol_verifyUser(long userId, List <Fingerprint> fingerprints, int threshold, MainWindow o) { //M3 AFISVerificationResult result = new AFISVerificationResult(); double dMaxScore = 0.0; if (!o.m_existFingerRegistry) { result.Score = 0; result.Hit = false; return(result); } Dermalog.Afis.FingerCode3.Matcher matcher = new Dermalog.Afis.FingerCode3.Matcher(); foreach (var f_template in o.m_fingers) { for (int j = 0; j < fingerprints.Count; j++) { double dScore = new Matcher().Match(f_template, fingerprints[j].Template); //double dScore = matcher.Match(f_template, fingerprints[j].Template); if (dScore > threshold && dScore > dMaxScore) { dMaxScore = dScore; result.Score = dMaxScore; result.Hit = true; } } } return(result); }
public AFISVerificationResult IdentifyUser_New(long userId, List <Fingerprint> fingerprints, int threshold) { AFISVerificationResult result = new AFISVerificationResult(); //if (!_userList.ContainsKey(userId)) //{ // throw new Exception("USER NOT REGISTERED"); //} LocalUser user = _userList_new[userId]; List <Fingerprint> userFingerprints = user.Fingerprints; double dMaxScore = 0.0; //for (int i = 0; i < userFingerprints.Count; i++) Parallel.ForEach(userFingerprints, (usertemplate, loopState) => { for (int j = 0; j < fingerprints.Count; j++) { double dScore = new Matcher().Match(usertemplate.Template, fingerprints[j].Template); //double dScore = new Matcher().Match(userFingerprints[i].Template, fingerprints[j].Template); if (dScore > threshold && dScore > dMaxScore) { dMaxScore = dScore; result.Score = dMaxScore; result.Hit = true; result.Hand = usertemplate.Hand.ToString(); result.HandPosition = Convert.ToInt32(usertemplate.Position).ToString(); loopState.Stop(); //return result; } } }); return(result); }
void _fpScanner_OnFingerprintsDetected(List <Fingerprint> fingerprints) { //ResetGUI(); //StopCapturing(); #region GUI - Display Fingerprints xamlStackPanelFingerprints.Children.Clear(); int imageWidth = (int)xamlStackPanelFingerprints.RenderSize.Width / fingerprints.Count; foreach (Fingerprint fingerprint in fingerprints) { System.Windows.Controls.Image img = new System.Windows.Controls.Image(); Bitmap bmp = new Bitmap(fingerprint.Image); img.Source = Utils.BitmapToBitmapSource(bmp); TextBlock tbNFIQ = new TextBlock(); tbNFIQ.Text = "NFIQ2: " + fingerprint.NFIQ2; tbNFIQ.FontSize = 80; tbNFIQ.TextAlignment = TextAlignment.Center; tbNFIQ.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; tbNFIQ.Foreground = Utils.GetBrushFromNFIQ2(fingerprint.NFIQ2); Grid grid = new Grid(); RowDefinition gridRow1 = new RowDefinition(); gridRow1.Height = new GridLength(1, GridUnitType.Star); RowDefinition gridRow2 = new RowDefinition(); gridRow2.Height = new GridLength(1, GridUnitType.Star); grid.RowDefinitions.Add(gridRow1); grid.RowDefinitions.Add(gridRow2); img.SetValue(Grid.RowProperty, 0); tbNFIQ.SetValue(Grid.RowProperty, 1); grid.Children.Add(img); grid.Children.Add(tbNFIQ); grid.Margin = new Thickness(30, 0, 30, 0); xamlStackPanelFingerprints.Children.Add(grid); } #endregion //if (_selectedUser != null) //{ try { //ResetGUI(); //StartCapturing(); //DisplayMessage("hola"); //Verify User DisplayMessage("Verificando huellas"); //AFISVerificationResult result = _afis.VerifyUser(_selectedUser.ID, fingerprints, Properties.Settings.Default.VerificationThreshold); AFISVerificationResult result = _afis.muserpol_verifyUser(0, fingerprints, Properties.Settings.Default.VerificationThreshold, this); String scoreString = String.Format("{0:0.00}", result.Score); //MessageBox.Show("hola como estan "); if (result.Hit) { displayMessage(String.Format("AFILIADO VERIFICADO ({0})", scoreString), Utils.COLOR_DERMALOG_GREEN); } else { if (result.Score < 0) { displayMessage(String.Format("AFILIADO NO BIOMETRIZADO ({0})", scoreString), Utils.COLOR_DERMALOG_BLUE); } else { displayMessage(String.Format("AFILIADO NO VERIFICADO ({0})", scoreString), Utils.COLOR_DERMALOG_RED); } } } catch (Exception e) { DisplayError(e.Message); } //} //dispose allocated fingerprint templates foreach (Fingerprint fingerprint in fingerprints) { fingerprint.Dispose(); } _fpScanner.Freeze(false); }
public static dynamic VERIFY_FingerPrints_METHOD(string refNO, Fingerprint fp, TemplateFormat template) { AFISVerificationResult result = new AFISVerificationResult(); dynamic verify_Result = new ExpandoObject(); //else { verify_Result.found = false; verify_Result.result = result; verify_Result.fingerPos = "not found"; } int threshold = 30; // Properties.Settings.Default.VerificationThreshold; //List<Fingerprint> fg = new List<Fingerprint>(); using (tranxDataContext tx = new tranxDataContext()) { tx.Connection.ConnectionString = getConnection(); var fng = tx.fingerprint_Tables.Select(s => s).Where(w => w.refNO == refNO); //lst_feedback.Items.Clear(); //foreach (fingerprint_Table_verify templateFile in fng) Parallel.ForEach(fng, (templateFile, loopState) => { //lst_feedback.Items.Insert(0, templateFile.refNO); byte[] data = Utils.convert_string2byteArray(templateFile.finger_data); //String templateFileString = Path.GetFileNameWithoutExtension(templateFile); String fingerPos = templateFile.position; Fingerprint fingerprint = new Fingerprint(); fingerprint.Template = new Template(); //fingerprint.Template.SetData(data, template); fingerprint.Template.Data = data; fingerprint.Template.Format = template; //fingerprint.Template.SetData(data, Dermalog.Afis.FingerCode3.Enums.TemplateFormat.Dermalog); //fingerprint.Position = UInt32.Parse(fingerPos); //fg.Add(fingerprint); double dScore = new Matcher().Match(fingerprint.Template, fp.Template); //double dScore = new Matcher().Match(userFingerprints[i].Template, fingerprints[j].Template); if (dScore > threshold) { //dMaxScore = dScore; result.Score = dScore;; result.Hit = true; //return result; verify_Result.found = true; verify_Result.result = result; verify_Result.fingerPos = fingerPos; //verify_Result.ClientName = Utils.get_finger_username(templateFile.refNO); //verify_Result.Name = templateFile.; //tx.SubmitChanges(); //str.Append(user.Value.Name); loopState.Stop(); } }); } return(verify_Result); }
void _fpScanner_OnFingerprintsDetected_new(List <Fingerprint> fingerprints) { #region GUI - Display Fingerprints fingerprints_new = fingerprints; #endregion Dictionary <long, LocalUser> userList = _afis.GetUserList(); xamlListBoxUsers.Items.Clear(); foreach (LocalUser user in userList.Values) { //xamlListBoxUsers.Items.Add(user); // } _selectedUser = user; // xamlStackPanelFingerprints.Controls.Add(fl); if (_selectedUser != null) { try { //Verify User DisplayMessage("Verifying Templates"); AFISVerificationResult result = _afis.VerifyUser(_selectedUser.ID, fingerprints, Properties.Settings.Default.VerificationThreshold); String scoreString = String.Format("{0:0.00}", result.Score); if (result.Score > maxMatch) { maxMatch = result.Score; } if (result.Hit) { displayMessage(String.Format("User verified ({0})", scoreString), Utils.COLOR_DERMALOG_GREEN); //label2.Text = String.Format("User verified ({0}%)", scoreString); //aGauge1.Value = (float)result.Score; break; } else { displayMessage(String.Format("User not verified ({0})", scoreString), Utils.COLOR_DERMALOG_RED); //label2.Text = String.Format("User verified ({0}%)", scoreString); //aGauge1.Value = (float)result.Score; } String bestscoreString = String.Format("{0:0.00}", maxMatch); label2.Text = String.Format("Best User verified ({0}%) username= {1}", bestscoreString, _selectedUser.Name); aGauge1.Value = (float)maxMatch; showAnimation(aGauge1); //StopCapturing(); //NewMethod(); } catch (Exception e) { DisplayError(e.Message); //StopCapturing(); } } { //this.BeginInvoke((MethodInvoker)delegate () //{ // NewMethod(); // Label l = new Label(); l.Location = new Point(12, 10); // l.Text = "Some Text"; // this.Controls.Add(l); //} //); //var resp; //Task.Factory.StartNew(()=>NewMethod_new()). } } //dispose allocated fingerprint templates foreach (Fingerprint fingerprint in fingerprints) { fingerprint.Dispose(); } _fpScanner.Freeze(false); }
void _fpScanner_OnFingerprintsDetected(List <Fingerprint> fingerprints) { #region GUI - Display Fingerprints fingerprints_new = fingerprints; // backgroundWorker1.RunWorkerAsync(); // xamlStackPanelFingerprints.Controls.Clear(); // int imageWidth = (int)xamlStackPanelFingerprints.Width / fingerprints.Count; // FlowLayoutPanel fl = new FlowLayoutPanel(); // file2ToolStripMenuItem.Width = xamlStackPanelFingerprints.Width; // file2ToolStripMenuItem.Height = xamlStackPanelFingerprints.Height; //foreach (Fingerprint fingerprint in fingerprints) //{ // // System.Windows.Controls.Image img = new System.Windows.Controls.Image(); // Bitmap bmp = new Bitmap(fingerprint.Image); // //img.Source = Utils.BitmapToBitmapSource(bmp); // //PictureBox pi = new PictureBox(); // //pi.Image = (Image)Utils.BitmapFromSource(Utils.BitmapToBitmapSource(bmp)); // System.Drawing.Image pi = (System.Drawing.Image) Utils.BitmapToBitmapSource2(bmp); // string str = string.Format("NFIQ: {0}", fingerprint.NFIQ); // // fPanel1.Controls.Add(addFinger(pi, str )); // fingerprint.Dispose(); // PictureBox p = new PictureBox(); // p.Image = pi; // //p.Image = global::DermalogMultiScannerDemo.Properties.Resources.fingers1; // //p.Location = new System.Drawing.Point(615, 22); // //p.Name = "pictureBox1"; // p.Dock = DockStyle.Fill; // p.Size = new System.Drawing.Size(100, 71); // p.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; // Label lb = new Label(); // lb.Text = str; // TableLayoutPanel tb = new TableLayoutPanel(); // tb.CellBorderStyle = TableLayoutPanelCellBorderStyle.OutsetDouble; // tb.ColumnCount = 1; // tb.RowCount = 2; // tb.Size = new System.Drawing.Size(123, 135); // //tb. // tb.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); // tb.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); // tb.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 80F)); // tb.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 20F)); // //Button b = new Button(); // tb.Controls.Add(p, 0, 0); // tb.Controls.Add(lb, 0, 1); // fPanel1.Controls.Add(tb); // // pi.Height = xamlStackPanelFingerprints.Height; // //pi.Width = imageWidth; // // Bitmap bmp = new Bitmap(fingerprint.Image); // // img.Source = Utils.BitmapToBitmapSource(bmp); // // TextBlock tbNFIQ = new TextBlock(); // // tbNFIQ.Text = "NFIQ: " + fingerprint.NFIQ; // // tbNFIQ.FontSize = 80; // // tbNFIQ.TextAlignment = TextAlignment.Center; // // tbNFIQ.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; // // tbNFIQ.Foreground = Utils.GetBrushFromNFIQ(fingerprint.NFIQ); // // Grid grid = new Grid(); // // RowDefinition gridRow1 = new RowDefinition(); // // gridRow1.Height = new GridLength(1, GridUnitType.Star); // // RowDefinition gridRow2 = new RowDefinition(); // // gridRow2.Height = new GridLength(1, GridUnitType.Star); // // grid.RowDefinitions.Add(gridRow1); // // grid.RowDefinitions.Add(gridRow2); // // img.SetValue(Grid.RowProperty, 0); // // tbNFIQ.SetValue(Grid.RowProperty, 1); // // grid.Children.Add(img); // // grid.Children.Add(tbNFIQ); // // grid.Margin = new Thickness(30, 0, 30, 0); // //fl.Controls.Add(pi); //} #endregion { this.BeginInvoke((MethodInvoker) delegate() { NewMethod(); } ); } // xamlStackPanelFingerprints.Controls.Add(fl); if (_selectedUser != null) { try { //Verify User DisplayMessage("Verifying Templates"); //Utils.bytetofile(@"C:\dermalog\Ayofutronics\futronic\dermalog2.dat", fingerprints.First().Template.Data); AFISVerificationResult result = _afis.VerifyUser_New(_selectedUser.ID, fingerprints, Properties.Settings.Default.VerificationThreshold); //AFISVerificationResult result = _afis.VerifyUser(_selectedUser.ID, fingerprints, Properties.Settings.Default.VerificationThreshold); String scoreString = String.Format("{0:0.00}", result.Score); if (result.Hit) { displayMessage(String.Format("User verified ({0}%)", scoreString), Utils.COLOR_DERMALOG_GREEN); //MessageBox.Show(String.Format("User verified ({0}%)", scoreString)); //label2.Text = String.Format("User verified ({0}%)", scoreString); //aGauge1.Value = (float)result.Score; if (result.Score > maxMatch) { maxMatch = result.Score; String bestscoreString = String.Format("{0:0.00}", maxMatch); label2.Text = String.Format("Best Finger verified ({0}%)", bestscoreString); aGauge1.Value = (float)maxMatch; CircleProgressbar1.Value = (int)maxMatch; //showAnimation(bunifuCards1); //showAnimation(bunifuCards2); //showAnimation(aGauge1); showAnimation(CircleProgressbar1); //StopCapturing(); scanBegin = false; } } else { displayMessage(String.Format("User not verified ({0}%)", scoreString), Utils.COLOR_DERMALOG_RED); //label2.Text = String.Format("User verified ({0}%)", scoreString); //aGauge1.Value = (float)result.Score; } //String bestscoreString = String.Format("{0:0.00}", maxMatch); //label2.Text = String.Format("Best User verified ({0}%)", bestscoreString); //aGauge1.Value = (float)maxMatch; //CircleProgressbar1.Value = (int)maxMatch; ////showAnimation(bunifuCards1); ////showAnimation(bunifuCards2); ////showAnimation(aGauge1); //showAnimation(CircleProgressbar1); ////StopCapturing(); scanBegin = false; DisplayError("Scanning Completed....."); MessageBox.Show("Scanning Completed.....view result"); picBusy.Visible = false; StopCapturing(); } catch (Exception e) { DisplayError(e.Message); //StopCapturing(); } } //dispose allocated fingerprint templates foreach (Fingerprint fingerprint in fingerprints) { fingerprint.Dispose(); } _fpScanner.Freeze(false); }