Esempio n. 1
0
        private void ProcessSingle(Object sender,FingerImage image)
        {
            try
            {
                if (isBusy && !isVerifyingPalm)
                {
                    return;
                }
                if (sender == currentDevice)
                {
                    FingerPicture pic = image.MakePicture();
                    showImage(pic);
                    if (isVerifyingPalm)
                    {
                        var verifyList = new List <FingerTemplate>();
                        verifyList.Add(currentDevice.Extract(image));
                        BiometricsEnrolled(this,verifyList);
                        return;
                    }

                    var candidates = new ComparsionCandidates(currentCredential.fingers);

                    /////////////
                    IDeviceControl        currDeviceControl;
                    List <FingerTemplate> matchedTemplates;
                    foreach (var devCtrl in Owner.PluginManager.DeviceControls)
                    {
                        if (devCtrl.ActiveDevices.Contains(currentDevice))
                        {
                            currDeviceControl = devCtrl;
                            int fingerIndex = currDeviceControl.Match(currentDevice.Extract(image),candidates.Candidates.ToArray(),out matchedTemplates);

                            if (fingerIndex == 0)
                            {
                                if (_controlType == ControlTypeEnum.FINGERPRINT_CONTROL_TYPE)
                                {
                                    fingerDisplay.ShowPopUp("Finger is not registered");
                                }
                                else if (_controlType == ControlTypeEnum.PALM_CONTROL_TYPE)
                                {
                                    fingerDisplay.ShowPopUp("Palm is not registered");
                                }
                                UpdateFingers();
                            }
                            else
                            {
                                if (_controlType == ControlTypeEnum.FINGERPRINT_CONTROL_TYPE)
                                {
                                    fingerDisplay.ShowPopUp("Finger is registered as " + FingerCredential.GetFingerName(candidates.PositionOf(matchedTemplates[0])));
                                    fingerChooser.ShowFinger(candidates.PositionOf(matchedTemplates[0]));
                                }
                                else if (_controlType == ControlTypeEnum.PALM_CONTROL_TYPE)
                                {
                                    fingerDisplay.ShowPopUp("Palm is registered as " + FingerCredential.GetFingerName(candidates.PositionOf(matchedTemplates[0])));
                                    if (candidates.PositionOf(matchedTemplates[0]) == 10)
                                    {
                                        if (highlightedPalm == 11)
                                        {
                                            palmEnrollControl.RightStatePalmP = StatePalm.WhiteBlack;
                                        }
                                        if (palmEnrollControl.LeftStatePalmP != StatePalm.Green)
                                        {
                                            palmEnrollControl.LeftStatePalmP = StatePalm.GreenBlack;
                                            highlightedPalm = 10;
                                        }
                                    }
                                    else if (candidates.PositionOf(matchedTemplates[0]) == 11)
                                    {
                                        if (highlightedPalm == 10)
                                        {
                                            palmEnrollControl.LeftStatePalmP = StatePalm.WhiteBlack;
                                        }
                                        if (palmEnrollControl.RightStatePalmP != StatePalm.Green)
                                        {
                                            palmEnrollControl.RightStatePalmP = StatePalm.GreenBlack;
                                            highlightedPalm = 11;
                                        }
                                    }
                                }
                                // Reset fingers after all
                                textReset = RESETER_TEXT_LIFETIME_MS;
                            }
                        }
                    }
                    /////////////
                    currentDevice.Dispatch(COMMAND.SINGLECAPTURE_START);
                }
            }
            catch (Exception ex)
            {
                //Log.Info(ex);
            }
        }
Esempio n. 2
0
        private void BiometricsEnrolled(Object sender,List <FingerTemplate> bios)
        {
            try
            {
                if (_controlType == ControlTypeEnum.PALM_CONTROL_TYPE)
                {
                    if (isVerifyingPalm == false)
                    {
                        enrollmentToVerify = bios;
                        isVerifyingPalm    = true;
                        currentDevice.Dispatch(COMMAND.SINGLECAPTURE_START);
                        return;
                    }
                }
                if (bios != null)
                {
                    // Check whether it is already enrolled

                    IDeviceControl        currDeviceControl = null;
                    List <FingerTemplate> matchedTemplates;
                    foreach (var devCtrl in Owner.PluginManager.DeviceControls)
                    {
                        if (devCtrl.ActiveDevices.Contains(currentDevice))
                        {
                            currDeviceControl = devCtrl;
                        }
                    }

                    if (isVerifyingPalm)
                    {
                        int matchesCount = currDeviceControl.Match(bios[0],enrollmentToVerify,out matchedTemplates);
                        isVerifyingPalm = false;
                    }
                    foreach (var user in Owner.Users)
                    {
                        if (user.SID == Owner.SID)
                        {
                            continue;
                        }
                        foreach (var fingerCred in user.credentials_List.OfType <FingerCredential>())
                        {
                            if (fingerCred.device.Equals(currentDevice.ToString()))
                            {
                                var candidates = new ComparsionCandidates(fingerCred.fingers);
                                foreach (var bio in bios)
                                {
//                                    int fingerIndex = currentDevice.Match(bio, candidates.Candidates);
                                    int matchesCount = currDeviceControl.Match(bio,candidates.Candidates,out matchedTemplates);
                                    if (matchesCount != 0)
                                    {
                                        Dispatcher.Invoke(new Action(() => showMessagePopup("Already registered as "
                                                                                            + FingerCredential.GetFingerName(candidates.PositionOf(matchedTemplates[0])) +
                                                                                            (_controlType == ControlTypeEnum.PALM_CONTROL_TYPE ? " " : " finger") +
                                                                                            " of user " +
                                                                                            user.ToString())));
                                        goto end;
                                    }
                                }
                            }
                        }
                    }
                    ////check if it is first time enrollment
                    if (currentCredential != null)
                    {
                        var candidates = new ComparsionCandidates(currentCredential.fingers);
                        foreach (var bio in bios)
                        {
                            //int fingerIndex = currentDevice.Match(bio, candidates.Candidates);
                            //if (fingerIndex != -1)
                            int matchesCount = currDeviceControl.Match(bio,candidates.Candidates,out matchedTemplates);
                            if (matchesCount != 0)
                            {
                                Dispatcher.Invoke(new Action(() => showMessagePopup("Already registered as "
                                                                                    + FingerCredential.GetFingerName(candidates.PositionOf(matchedTemplates[0])) +
                                                                                    (_controlType == ControlTypeEnum.PALM_CONTROL_TYPE ? " " : " finger") +
                                                                                    " of user " +
                                                                                    Owner.Username)));
                                goto end;
                            }
                        }
                    }
                    ////
                    if (_controlType == ControlTypeEnum.FINGERPRINT_CONTROL_TYPE)
                    {
                        foreach (var tmpl in bios)
                        {
                            String str = Convert.ToBase64String(tmpl.Serialize());
                            currentCredential.AddFinger(new Finger(fingerNum,str,tmpl));
                        }
                    }
                    else if (_controlType == ControlTypeEnum.PALM_CONTROL_TYPE)
                    {
                        showMessagePopup((fingerNum == 10 ? "Left palm" : "Right palm") + " has been successfully registered");
                        foreach (var tmpl in enrollmentToVerify)
                        {
                            String str = Convert.ToBase64String(tmpl.Serialize());
                            currentCredential.AddFinger(new Finger(fingerNum,str,tmpl));
                        }
                    }
                }

end:
                Task.Factory.StartNew(() =>
                {
                    Dispatcher.Invoke(new Action(() => endEnrollment()));
                });
            }
            catch (Exception ex)
            {
                Log.Error("enrollment exception" + ex);
            }
        }