Exemplo n.º 1
0
        private void StartCapturing()
        {
            if (_biometricClient.FaceCaptureDevice == null)
            {
                MessageBox.Show(@"Please select camera from the list");
                return;
            }
            // Set face capture from stream
            var face = new NFace {
                CaptureOptions = NBiometricCaptureOptions.Manual
            };

            _subject = new NSubject();
            _subject.Faces.Add(face);
            facesView.Face = face;
            _biometricClient.FacesDetectAllFeaturePoints = true;
            // Begin capturing faces
            _biometricClient.BeginCapture(_subject, OnCapturingCompleted, null);
            lblStatus.Text = string.Empty;
            EnableControls(true);

            ////_task = _biometricClient.CreateTask(NBiometricOperations.Capture | NBiometricOperations.Enroll | NBiometricOperations.Segment | NBiometricOperations.AssessQuality, _subject);
            ////_biometricClient.PerformTask(_task);
            ////if (_task.Status == NBiometricStatus.Ok)
            ////{
            ////    pictureBoxCroped.Image = _subject.Faces[0].Image.ToBitmap();
            ////    _croppedPhotoImage = _subject.Faces[0].Image.ToBitmap();
            ////}
        }
Exemplo n.º 2
0
        private void VerificationOperationInit()
        {
            VerificationOperationButtonconfig();
            lblInfo.Text = Resources.Capturing_user___;
            _subject     = new NSubject();
            var face = new NFace {
                CaptureOptions = NBiometricCaptureOptions.Stream
            };

            _subject.Faces.Add(face);
            nlockLoginFaceView.Face = _subject.Faces[0];
            _currentop = Ops.Ongoing;
            _biometricClient.BeginCapture(_subject, OnCapturingCompleted, null);
        }
Exemplo n.º 3
0
        private void OnCapturingComplete(IAsyncResult r)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new AsyncCallback(OnCapturingComplete), r);
            }
            else
            {
                try
                {
                    var status = _biometricClient.EndCapture(r);

                    if (status == NBiometricStatus.Ok)
                    {
                        TemplateLoginForm = _subject.GetTemplateBuffer().ToArray();

                        _enumoperation = Modes.Initialization;
                        if (_subject.Faces.Count > 1)
                        {
                            TemplateLoginForm = null;
                            lblInfo.Text      = Resources.ManyFaces;
                            lblInfo.ForeColor = Color.Red;
                            CapturingOperationInit();
                            _subject.Faces[0].Image = null;
                            _biometricClient.BeginCapture(_subject, OnCapturingComplete, null);
                        }
                        else
                        {
                            CloseButtonCapSuccessConfig();
                            _enumoperation = Modes.Capturesuccess;
                        }
                    }
                    else
                    {
                        TemplateLoginForm = null;

                        lblInfo.Text      = Resources.RestartCapture + "\n" + status;
                        lblInfo.ForeColor = Color.Red;
                        CapturingOperationInit();
                        _enumoperation          = Modes.Initialization;
                        _subject.Faces[0].Image = null;
                        _biometricClient.BeginCapture(_subject, OnCapturingComplete, null);
                    }
                }
                catch (InvalidOperationException)
                {
                    CheckCamera();
                    CheckLicense();
                    CapturingOperationInit();
                    _enumoperation = Modes.Initialization;
                }
                catch (Exception)
                {
                    CheckCamera();
                    CheckLicense();
                    CapturingOperationInit();

                    _enumoperation = Modes.Initialization;
                }
            }
        }