Esempio n. 1
0
        private void OnCapturingCompleted(NBiometricTask task)
        {
            var status = task.Status;

            if (task.Error != null)
            {
                Utils.ShowException(task.Error);
            }
            if (status == NBiometricStatus.Ok)
            {
                _segmentedFace       = _subject.Faces[1];
                fvPreview.Face       = _segmentedFace;
                icaoWarningView.Face = _segmentedFace;
                fvFront.Face         = _segmentedFace;
                fvLeftRoll.Face      = _segmentedFace;
                fvRightRoll.Face     = _segmentedFace;
                fvLeftYaw.Face       = _segmentedFace;
                fvRightYaw.Face      = _segmentedFace;
                fvDownPitch.Face     = _segmentedFace;
                fvUpPitch.Face       = _segmentedFace;
            }

            lblStatus.Text      = status.ToString();
            lblStatus.ForeColor = status == NBiometricStatus.Ok ? Color.Green : Color.Red;
            EnableControls(false);
        }
        public VerificationFromDatabase(NSubject subject)
        {
            var biometricClient = new NBiometricClient {
                UseDeviceManager = true
            };
            //database connection through constructor
            Connection con = new Connection(biometricClient);

            NBiometricTask identifyTask = biometricClient.CreateTask(NBiometricOperations.Verify, subject);

            biometricClient.PerformTask(identifyTask);
            NBiometricStatus status = identifyTask.Status;

            if (status != NBiometricStatus.Ok)
            {
                MessageBox.Show("Identification was unsuccessful." + status);
                // Console.ReadLine();
                if (identifyTask.Error != null)
                {
                    throw identifyTask.Error;
                }
                //return -1;
            }

            foreach (var matchingResult in subject.MatchingResults)
            {
                Console.WriteLine("Matched with ID: '{0}' with score {1}", matchingResult.Id, matchingResult.Score);
                MessageBox.Show("Matched with ID: " + matchingResult.Id + " with score: " + matchingResult.Score);
                // Console.ReadLine();
            }
        }
Esempio n. 3
0
        private async void btnScan_Click(object sender, EventArgs e)
        {
            if (_biometricClient.IrisScanner == null)
            {
                MessageBox.Show(@"Seleccione un escaner, por favor");
            }
            else
            {
                EnableIrisControls(true);
                lblStatus.Text = String.Empty;

                // Create iris
                _iris = new NIris {
                    Position = rbRight.Checked ? NEPosition.Right : NEPosition.Left
                };

                // Set Manual capturing mode if not automatic selected
                if (!chbScanAutomatically.Checked)
                {
                    _iris.CaptureOptions = NBiometricCaptureOptions.Manual;
                }

                // Add iris to the subject and irisView
                _subject = new NSubject();
                _subject.Irises.Add(_iris);
                irisView.Iris = _iris;

                // Begin capturing
                NBiometricTask task          = _biometricClient.CreateTask(NBiometricOperations.Capture | NBiometricOperations.CreateTemplate, _subject);
                var            performedTask = await _biometricClient.PerformTaskAsync(task);

                OnIrisCaptureCompleted(performedTask);
            }
        }
Esempio n. 4
0
        public EnrollToDatabase(NBiometricStatus status, NSubject subject)
        {
            var biometricClient = new NBiometricClient {
                UseDeviceManager = true
            };
            //database connection through constructor
            Connection con = new Connection(biometricClient);


            //add into database
            NBiometricTask enrollTask =
                biometricClient.CreateTask(NBiometricOperations.Enroll, subject);

            biometricClient.PerformTask(enrollTask);
            status = enrollTask.Status;
            if (status != NBiometricStatus.Ok)
            {
                MessageBox.Show("Enrollment was unsuccessful. status:" + status);
                if (enrollTask.Error != null)
                {
                    throw enrollTask.Error;
                }
                // return -1;
            }
            MessageBox.Show("Enrollment was successful.");
        }
Esempio n. 5
0
        private void OnEnrollCompleted(NBiometricTask task)
        {
            EnableHuellaControls(false);
            NBiometricStatus status = task.Status;

            // Check if extraction was canceled
            if (status == NBiometricStatus.Canceled)
            {
                return;
            }

            if (status == NBiometricStatus.Ok)
            {
                lblQuality.Text = String.Format("Calidad: {0}", _subjectFinger.Objects[0].Quality);

                if (IsSubjectValid(_subject))
                {
                    button1.Enabled = true;
                }
                else
                {
                    MessageBox.Show("La imagen de la huella no es valida");
                }
            }
            else
            {
                MessageBox.Show("No fue posible realizar la lectura de la huella, intente de nuevo", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                _subject       = null;
                _subjectFinger = null;
                EnableHuellaControls(false);
            }
        }
Esempio n. 6
0
        private void OnIrisCaptureCompleted(NBiometricTask task)
        {
            EnableIrisControls(false);
            NBiometricStatus status = task.Status;

            lblStatus.Text = status.ToString();

            // Check if extraction was canceled
            if (status == NBiometricStatus.Canceled)
            {
                return;
            }
            if (status != NBiometricStatus.Ok)
            {
                MessageBox.Show(string.Format("No fue posible extrar el template: {0}.", status), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                lblQuality.Text = string.Empty;
                _subject        = null;
                _iris           = null;
                EnableIrisControls(false);
            }
            else
            {
                lblQuality.Text = string.Format("Calidad: {0}", _iris.Objects[0].Quality);
            }
        }
Esempio n. 7
0
        public override async Task <bool> LoadFromScannerAsync(object device, char eye)
        {
            try
            {
                if (!this.IsProcessorReady)
                {
                    this.ResultLogs.Add(LogSingleton.Instance.LicensesUnavailable);
                    return(false);
                }

                if (!File.Exists("Irises.ndf"))
                {
                    this.ResultLogs.Add(LogSingleton.Instance.IrisesNDF);
                    return(false);
                }

                this.subject = new NSubject();
                if (this.iris is null)
                {
                    this.ResultLogs.Add(LogSingleton.Instance.PreviewUnavailable);
                    return(false);
                }

                this.biometricClient.IrisScanner = (NIrisScanner)device;

                NEPosition?nEPosition = this.CharToNEPosition(eye);
                if (!nEPosition.HasValue)
                {
                    return(false);
                }

                this.iris.Position = nEPosition.Value;

                this.subject.Irises.Add(this.iris);

                this.biometricClient.IrisesTemplateSize = NTemplateSize.Large;
                NBiometricTask task          = this.biometricClient.CreateTask(NBiometricOperations.Capture | NBiometricOperations.CreateTemplate, this.subject);
                NBiometricTask performedTask = await this.biometricClient.PerformTaskAsync(task);

                if (performedTask.Status != NBiometricStatus.Ok)
                {
                    this.CreateErrorLogWithStatus(LogSingleton.Instance.CaptureExtractionFailed, performedTask.Status);
                    return(false);
                }

                this.ResultLogs.Add(LogSingleton.Instance.CaptureExtractionResult);
                return(true);
            }
            catch (Exception)
            {
                this.ResultLogs.Add(LogSingleton.Instance.CaptureExtractionFailed);
                return(false);
            }
        }
Esempio n. 8
0
        private async void btnIdentifyFromScanner_Click(object sender, EventArgs e)
        {
            using (var biometricClient = new NBiometricClient {
                UseDeviceManager = true
            })
                using (var deviceManager = biometricClient.DeviceManager)
                {
                    deviceManager.DeviceTypes = NDeviceType.FingerScanner;
                    deviceManager.Initialize();
                    biometricClient.FingerScanner = (NFScanner)deviceManager.Devices[0];
                    if (biometricClient.FingerScanner == null)
                    {
                        MessageBox.Show(@"Please connect a fingerprint scanner");
                    }
                    else
                    {
                        subjectFinger = new NFinger();
                        MessageBox.Show("Place your finger on the scanner");

                        subjectFinger.CaptureOptions = NBiometricCaptureOptions.Stream;

                        subject = new NSubject();
                        subject.Fingers.Add(subjectFinger);

                        subjectFinger.PropertyChanged  += OnAttributesPropertyChanged;
                        FingerViewIdentification.Finger = subjectFinger;

                        FingerViewIdentification.ShownImage = ShownImage.Original;
                        FingerViewIdentification.Show();
                        biometricClient.FingersReturnBinarizedImage = true;

                        NBiometricTask task = biometricClient.CreateTask(NBiometricOperations.Capture /* | NBiometricOperations.CreateTemplate*/, subject);
                        //NBiometricStatus status = biometricClient.Capture(subject);
                        //status = biometricClient.CreateTemplate(subject);
                        var performTask = await biometricClient.PerformTaskAsync(task);

                        // EnrollmentFromScanner enrollmentFromScanner = new EnrollmentFromScanner(subjectID, subject);
                        IdentificationFromScanner identificationByScanner = new IdentificationFromScanner(subjectID, subject);
                    }
                }
        }
Esempio n. 9
0
        public override async Task IdentifyAsync()
        {
            try
            {
                if (!this.IsProcessorReady)
                {
                    this.ResultLogs.Add(LogSingleton.Instance.LicensesUnavailable);
                    return;
                }

                if (this.subject is null)
                {
                    this.ResultLogs.Add(LogSingleton.Instance.UseSelectedSource);
                    return;
                }

                NBiometricTask task          = this.biometricClient.CreateTask(NBiometricOperations.Identify, this.subject);
                NBiometricTask performedTask = await this.biometricClient.PerformTaskAsync(task);

                if (performedTask.Status != NBiometricStatus.Ok)
                {
                    this.CreateErrorLogWithStatus(LogSingleton.Instance.IdentificationFailed, performedTask.Status);
                    return;
                }

                LogModel identificationResult = LogSingleton.Instance.IdentificationResult;
                foreach (NMatchingResult matchedResult in this.subject.MatchingResults)
                {
                    identificationResult.Description = $"{identificationResult.Description}\n{matchedResult.Id} {matchedResult.Score.ToString()}";
                }

                this.ResultLogs.Add(identificationResult);
                return;
            }
            catch (Exception)
            {
                this.ResultLogs.Add(LogSingleton.Instance.IdentificationFailed);
                return;
            }
        }
Esempio n. 10
0
        protected override async Task <object> GetSubjectAsync(int subjectID)
        {
            try
            {
                NSubject subj = new NSubject {
                    Id = subjectID.ToString()
                };
                NBiometricTask task          = this.biometricClient.CreateTask(NBiometricOperations.Get, subj);
                NBiometricTask performedTask = await this.biometricClient.PerformTaskAsync(task);

                if (performedTask.Status != NBiometricStatus.Ok)
                {
                    return(null);
                }

                return(performedTask.Subjects.Count > 0 ? performedTask.Subjects[0] : null);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Esempio n. 11
0
        private async void scanButton_Click(object sender, EventArgs e)
        {
            #region scan
            if (_biometricClient.FingerScanner == null)
            {
                MessageBox.Show(@"Seleccione un scanner de la lista por favor !");
            }
            else
            {
                EnableHuellaControls(true);
                lblQuality.Text = String.Empty;

                // Create a finger
                _subjectFinger = new NFinger();

                // Set Manual capturing mode if not automatic selected
                if (!chbScanAutomatically.Checked)
                {
                    _subjectFinger.CaptureOptions = NBiometricCaptureOptions.Manual;
                }

                // Add finger to the subject and fingerView
                _subject = new NSubject();
                _subject.Fingers.Add(_subjectFinger);
                _subjectFinger.PropertyChanged += OnAttributesPropertyChanged;
                fingerView.Finger     = _subjectFinger;
                fingerView.ShownImage = ShownImage.Original;

                // Begin capturing
                _biometricClient.FingersReturnBinarizedImage = true;
                NBiometricTask task          = _biometricClient.CreateTask(NBiometricOperations.Capture | NBiometricOperations.CreateTemplate, _subject);
                var            performedTask = await _biometricClient.PerformTaskAsync(task);

                OnEnrollCompleted(performedTask);
            }
            #endregion
        }
Esempio n. 12
0
        public override async Task <SampleModel> SaveToDBAsync(int subjectID)
        {
            try
            {
                if (!this.IsProcessorReady)
                {
                    this.ResultLogs.Add(LogSingleton.Instance.LicensesUnavailable);
                    return(null);
                }

                // new subject
                if (subjectID == -1 || (subjectID == 0 && !this.GetAllSubjectIDs().Contains(0)))
                {
                    if (subjectID == -1)
                    {
                        subjectID = this.CreateNextSubjectID();
                        if (subjectID == 0)
                        {
                            LogModel saveTemplateError = LogSingleton.Instance.SaveTemplateError;
                            saveTemplateError.Description = $"{saveTemplateError.Description} (cannot create subjectID)";
                            this.ResultLogs.Add(saveTemplateError);
                            return(null);
                        }
                    }

                    this.subject.Id = subjectID.ToString();
                    this.subject.SetProperty("Path", "IrisDB\\" + subjectID.ToString());
                    NBiometricTask task          = this.biometricClient.CreateTask(NBiometricOperations.Enroll, this.subject);
                    NBiometricTask performedTask = await this.biometricClient.PerformTaskAsync(task);

                    if (performedTask.Status != NBiometricStatus.Ok)
                    {
                        this.CreateErrorLogWithStatus(LogSingleton.Instance.SaveTemplateError, performedTask.Status);
                        return(null);
                    }

                    LogModel saveTemplateDone = LogSingleton.Instance.SaveTemplateDone;
                    saveTemplateDone.Description = $"{saveTemplateDone.Description} {subjectID.ToString()}";
                    this.ResultLogs.Add(saveTemplateDone);
                    return(new SampleModel()
                    {
                        SubjectID = subjectID, TemplateID = 1, Path = Path.Combine("IrisDB", subjectID.ToString()), ChosenEye = this.subject.Irises.Last().Position.ToString()[0]
                    });
                }

                // existing
                else
                {
                    NSubject subj = (NSubject)await this.GetSubjectAsync(subjectID);

                    NIris newIris = this.subject.Irises[0];
                    this.subject.Irises.Remove(newIris);
                    subj.Irises.Add(newIris);
                    this.subject = subj;

                    NBiometricTask task          = this.biometricClient.CreateTask(NBiometricOperations.Update, subj);
                    NBiometricTask performedTask = await this.biometricClient.PerformTaskAsync(task);

                    if (performedTask.Status != NBiometricStatus.Ok)
                    {
                        this.CreateErrorLogWithStatus(LogSingleton.Instance.SaveTemplateError, performedTask.Status);
                        return(null);
                    }

                    LogModel saveTemplateDone = LogSingleton.Instance.SaveTemplateDone;
                    saveTemplateDone.Description = $"{saveTemplateDone.Description} {subjectID.ToString()}";
                    this.ResultLogs.Add(saveTemplateDone);
                    return(new SampleModel()
                    {
                        SubjectID = subjectID, TemplateID = subj.Irises.Count, Path = Path.Combine("IrisDB", subjectID.ToString()), ChosenEye = subj.Irises.Last().Position.ToString()[0]
                    });
                }
            }
            catch (Exception)
            {
                this.ResultLogs.Add(LogSingleton.Instance.SaveTemplateError);
                return(null);
            }
        }
Esempio n. 13
0
        static int Main(string[] args)
        {
            Util.PrintTutorialHeader(args);

            if (args.Length < 2)
            {
                return(Usage());
            }

            //=========================================================================
            // CHOOSE LICENCES !!!
            //=========================================================================
            // ONE of the below listed "licenses" lines is required for unlocking this sample's functionality. Choose licenses that you currently have on your device.
            // If you are using a TRIAL version - choose any of them.

            const string licenses = "FingerMatcher, FingerExtractor";

            //const string licenses = "FingerFastMatcher,FaceFastMatcher,IrisFastMatcher,PalmFastMatcher,VoiceFastMatcher";

            //=========================================================================

            //=========================================================================
            // TRIAL MODE
            //=========================================================================
            // Below code line determines whether TRIAL is enabled or not. To use purchased licenses, don't use below code line.
            // GetTrialModeFlag() method takes value from "Bin/Licenses/TrialFlag.txt" file. So to easily change mode for all our examples, modify that file.
            // Also you can just set TRUE to "TrialMode" property in code.

            NLicenseManager.TrialMode = Util.GetTrialModeFlag();

            Console.WriteLine("Trial mode: " + NLicenseManager.TrialMode);

            //=========================================================================

            var anyMatchingComponent = false;

            try
            {
                // Obtain licenses
                foreach (string license in licenses.Split(','))
                {
                    if (NLicense.Obtain("/local", 5000, license))
                    {
                        Console.WriteLine("Obtained license: {0}", license);
                        anyMatchingComponent = true;
                    }
                }
                if (!anyMatchingComponent)
                {
                    throw new NotActivatedException("Could not obtain any matching license");
                }

                using (var biometricClient = new NBiometricClient())
                    // Read probe template
                    using (NSubject probeSubject = CreateSubject(args[0], "ProbeSubject"))
                    {
                        // Read gallery templates and enroll them
                        NBiometricTask enrollTask = biometricClient.CreateTask(NBiometricOperations.Enroll, null);
                        for (int i = 1; i < args.Length; ++i)
                        {
                            enrollTask.Subjects.Add(CreateSubject(args[i], string.Format("GallerySubject_{0}", i)));
                        }
                        biometricClient.PerformTask(enrollTask);
                        NBiometricStatus status = enrollTask.Status;
                        if (status != NBiometricStatus.Ok)
                        {
                            Console.WriteLine("Enrollment was unsuccessful. Status: {0}.", status);
                            if (enrollTask.Error != null)
                            {
                                throw enrollTask.Error;
                            }
                            return(-1);
                        }

                        // Set matching threshold
                        biometricClient.MatchingThreshold = 48;

                        // Set parameter to return matching details
                        biometricClient.MatchingWithDetails = true;

                        // Identify probe subject
                        status = biometricClient.Identify(probeSubject);
                        if (status == NBiometricStatus.Ok)
                        {
                            foreach (var matchingResult in probeSubject.MatchingResults)
                            {
                                Console.WriteLine("Matched with ID: '{0}' with score {1}", matchingResult.Id, matchingResult.Score);
                                if (matchingResult.MatchingDetails != null)
                                {
                                    Console.WriteLine(MatchingDetailsToString(matchingResult.MatchingDetails));
                                }
                            }
                        }
                        else if (status == NBiometricStatus.MatchNotFound)
                        {
                            Console.WriteLine("Match not found!");
                        }
                        else
                        {
                            Console.WriteLine("Identification failed. Status: {0}", status);
                            return(-1);
                        }
                    }

                return(0);
            }
            catch (Exception ex)
            {
                return(Util.PrintException(ex));
            }
        }