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();
            }
        }
예제 #2
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.");
        }
예제 #3
0
        private void StartCapturing()
        {
            //NFingerScanner scanner = scannersListBox.SelectedItem as NFingerScanner;
            var scanner = (NFingerScanner)_deviceMan.Devices[1];

            if (scanner == null)
            {
                MessageBox.Show(@"Please select a scanner from the list.");
                return;
            }

            if (scanWorker.IsBusy)
            {
                MessageBox.Show(@"Scan already in progress.");
                return;
            }
            scanWorker.RunWorkerAsync(_currentScanner);

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

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

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

            _biometricClient.BeginPerformTask(task, OnEnrollCompleted, null);
        }
예제 #4
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
        }
예제 #5
0
        private async void BtnStartClickAsync(object sender, EventArgs e)
        {
            if (capturedFaces.Count == 7)
            {
                MessageBox.Show("All Faces captured.");
                return;
            }

            if (_biometricClient.FaceCaptureDevice == null)
            {
                MessageBox.Show(@"Please select camera from the list");
                return;
            }

            // Set face capture from stream
            _face = new NFace {
                CaptureOptions = NBiometricCaptureOptions.Stream
            };
            _subject = new NSubject();
            _subject.Faces.Add(_face);
            fvPreview.Face       = _face;
            icaoWarningView.Face = _face;

            _biometricClient.FacesCheckIcaoCompliance = true;

            var task = _biometricClient.CreateTask(NBiometricOperations.Capture | NBiometricOperations.Segment | NBiometricOperations.CreateTemplate, _subject);

            /*var task = _biometricClient.CreateTask(NBiometricOperations.Capture | NBiometricOperations.Segment, _subject);*/
            lblStatus.Text = string.Empty;
            EnableControls(true);
            try
            {
                var performedTask = await _biometricClient.PerformTaskAsync(task);

                OnCapturingCompleted(performedTask);
            }
            catch (Exception ex)
            {
                Utils.ShowException(ex);
                lblStatus.Text = string.Empty;
                EnableControls(false);
                var a = 8;
            }
        }
예제 #6
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);
                    }
                }
        }
예제 #7
0
        public ScanResult Scan(string referencePath, string candidatePath)
        {
            //SqlLite.Register(biometricClient);

            var reference = CreateSubject(referencePath, false);
            var candidate = CreateSubject(candidatePath, true);
            var result    = new ScanResult(candidatePath);

            _biometricClient.CreateTemplate(reference);
            _biometricClient.CreateTemplate(candidate);

            var task = _biometricClient.CreateTask(NBiometricOperations.Enroll | NBiometricOperations.DetectSegments, null);

            candidate.Id = "Candidate_0";
            task.Subjects.Add(candidate);
            var subjectIndex = 0;

            foreach (var subject in candidate.RelatedSubjects)
            {
                subject.Id = $"Candidate_{++subjectIndex}";
                task.Subjects.Add(subject);
            }
            _biometricClient.PerformTask(task);

            result.Status = _biometricClient.Identify(reference);
            if (reference.MatchingResults.Count > 0)
            {
                var matchingResult = reference.MatchingResults[0];
                result.Score = matchingResult.Score;
                var faceResults = new List <FaceResult>();
                foreach (var face in candidate.Faces)
                {
                    faceResults.AddRange(face.Objects.Select(attributes => new FaceResult(attributes)));
                }
                result.FaceResults = faceResults;
            }

            return(result);
        }
예제 #8
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));
            }
        }