Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }