예제 #1
0
        public void LoadTestFingerPrintImages(string imageDirectory)
        {
            DirectoryInfo dirInfo     = new DirectoryInfo(imageDirectory);
            Fingerprint   fingerprint = null;

            if (dirInfo.Exists)
            {
                foreach (DirectoryInfo dir in dirInfo.GetDirectories())
                {
                    foreach (DirectoryInfo dirSub in dir.GetDirectories())
                    {
                        foreach (DirectoryInfo dirSub2 in dirSub.GetDirectories())
                        {
                            foreach (FileInfo file in dirSub2.GetFiles())
                            {
                                fingerprint = new Fingerprint();
                                fingerprint.AsBitmapSource = WpfIO.Load(file.FullName);
                                if (fingerprint.Image != null)
                                {
                                    Afis.ExtractFingerprint(fingerprint);
                                    fingerprintList.Add(fingerprint.GetTemplate());
                                    PatientFingerprintMinutia dbFingerprintMinutia = new PatientFingerprintMinutia(nextID, 1, fingerprint.GetTemplate());
                                    dbFingerprintMinutiaList.Add(dbFingerprintMinutia);
                                    nextID = nextID + 1;
                                }
                            }
                        }
                    }
                }
                _probe = fingerprint;
            }
            SerializeDatabaseProto serialize = new SerializeDatabaseProto();

            serialize.WriteToDisk(DATABASE_PATH + @"finger.hive.0001.biodb", dbFingerprintMinutiaList);
        }
예제 #2
0
        public void LoadTestFingerPrintImages(string imageDirectory, bool breakAtOneHundred = false)
        {
            DirectoryInfo dirInfo     = new DirectoryInfo(imageDirectory);
            Fingerprint   fingerprint = null;

            if (dirInfo.Exists)
            {
                foreach (DirectoryInfo dir in dirInfo.GetDirectories())
                {
                    foreach (DirectoryInfo dirSub in dir.GetDirectories())
                    {
                        foreach (DirectoryInfo dirSub2 in dirSub.GetDirectories())
                        {
                            foreach (FileInfo file in dirSub2.GetFiles())
                            {
                                fingerprint = new Fingerprint();
                                fingerprint.AsBitmapSource = WpfIO.Load(file.FullName);
                                if (fingerprint.Image != null)
                                {
                                    Afis.ExtractFingerprint(fingerprint);
                                    Template template = fingerprint.GetTemplate();
                                    template.NoID.LocalNoID = "Test" + nextID.ToString();
                                    dbMinutia.AddTemplate(template);
                                    nextID++;
                                    if (breakAtOneHundred && nextID > 10)
                                    {
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        public float SearchTest(Fingerprint probe = null)
        {
            if (probe == null)
            {
                probe = _probe;
            }

            Afis.ExtractFingerprint(probe);
            Afis.Threshold = MATCH_THRESHOLD;
            return(Afis.IdentifyFinger(probe.GetTemplate(), fingerprintList));
        }
예제 #4
0
        //TODO: Abstract CaptureResult so it will work with any fingerprint scanner.
        private void OnCaptured(CaptureResult captureResult)
        {
            browser.GetMainFrame().ExecuteJavaScriptAsync("showPleaseWait();");
            //mark schroeder20170703
            if (PatientBridge.cannotCaptureLeftFingerprint == true)
            {
                Laterality = FHIRUtilities.LateralitySnoMedCode.Right;
            }

            if (currentCaptureInProcess == false)
            {
                if ((PatientBridge.hasValidLeftFingerprint == true && Laterality == FHIRUtilities.LateralitySnoMedCode.Left) || (PatientBridge.hasValidRightFingerprint == true && Laterality == FHIRUtilities.LateralitySnoMedCode.Right))
                {
                    //mark schroeder 20170701 do not capture more left fingerprints if left is set. Same for right
                    return;
                }
                else
                {
                    try
                    {
                        //mark schroeder 20170701 use this to stop more capture attempts while processing. Added to below if statememt
                        currentCaptureInProcess    = true;
                        maxFingerprintScanAttempts = Convert.ToInt16(System.Configuration.ConfigurationManager.AppSettings["maxFingerprintScanAttempts"].ToString());
                        fingerprintScanAttempts++;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        return;
                    }

                    if (_patientBridge.captureSite != FHIRUtilities.CaptureSiteSnoMedCode.Unknown && _patientBridge.laterality != FHIRUtilities.LateralitySnoMedCode.Unknown)
                    {
                        if (fingerprintScanAttempts <= maxFingerprintScanAttempts)
                        {
#if NAVIGATE
                            DisplayOutput("Captured finger image....");
#endif
                            // Check capture quality and throw an error if poor or incomplete capture.
                            if (!biometricDevice.CheckCaptureResult(captureResult))
                            {
                                return;
                            }

                            Constants.CaptureQuality quality = captureResult.Quality;
                            if ((int)quality != 0)
                            {
                                //call javascript to inform UI that the capture quality was too low to accept.
#if NAVIGATE
                                DisplayOutput("Fingerprint quality was too low to accept. Quality = " + quality.ToString());
#endif
                                return;
                            }

                            Type   captureResultType = captureResult.GetType();
                            string deviceClassName   = captureResultType.ToString();
                            string deviceName        = "";
                            if (deviceClassName == "DPUruNet.CaptureResult")
                            {
                                deviceName = "DigitalPersona U.Are.U 4500";
                            }

                            SourceAFIS.Simple.Person currentCapture = new SourceAFIS.Simple.Person();

                            Fingerprint newFingerPrint = new Fingerprint();
                            foreach (Fid.Fiv fiv in captureResult.Data.Views)
                            {
                                newFingerPrint.AsBitmap = ImageUtilities.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height);
                            }
                            currentCapture.Fingerprints.Add(newFingerPrint);
                            Afis.Extract(currentCapture);
                            Template tmpCurrent = newFingerPrint.GetTemplate();

                            if (_minutiaCaptureController.MatchFound == false)
                            {
                                if (_minutiaCaptureController.AddMinutiaTemplateProbe(tmpCurrent) == true)
                                {
                                    // Good pair found.  Query web service for a match.
                                    FingerPrintMinutias newFingerPrintMinutias = new FingerPrintMinutias
                                                                                     (SessionID, _minutiaCaptureController.BestTemplate1, Laterality, CaptureSite);
                                    PatientBridge.PatientFHIRProfile.AddFingerPrint(newFingerPrintMinutias,
                                                                                    deviceName,
                                                                                    _minutiaCaptureController.BestTemplate1.OriginalDpi,
                                                                                    _minutiaCaptureController.BestTemplate1.OriginalHeight,
                                                                                    _minutiaCaptureController.BestTemplate1.OriginalWidth);

                                    newFingerPrintMinutias = new FingerPrintMinutias
                                                                 (SessionID, _minutiaCaptureController.BestTemplate2, Laterality, CaptureSite);
                                    PatientBridge.PatientFHIRProfile.AddFingerPrint(newFingerPrintMinutias,
                                                                                    deviceName,
                                                                                    _minutiaCaptureController.BestTemplate2.OriginalDpi,
                                                                                    _minutiaCaptureController.BestTemplate2.OriginalHeight,
                                                                                    _minutiaCaptureController.BestTemplate2.OriginalWidth);

                                    Media media = PatientBridge.PatientFHIRProfile.FingerPrintFHIRMedia(newFingerPrintMinutias, deviceName, tmpCurrent.OriginalDpi, tmpCurrent.OriginalHeight, tmpCurrent.OriginalWidth);

                                    // TODO: REMOVE THIS LINE!  ONLY FOR TESTING
                                    //FHIRUtilities.SaveJSONFile(media, @"C:\JSONTest");

                                    HttpsClient    dataTransport = new HttpsClient();
                                    Authentication auth;
                                    if (Utilities.Auth == null)
                                    {
                                        auth = SecurityUtilities.GetAuthentication(NoIDServiceName);
                                    }
                                    else
                                    {
                                        auth = Utilities.Auth;
                                    }
                                    PatientBridge.fhirAddress = new Uri(SearchBiometricsUri);
                                    dataTransport.SendFHIRMediaProfile(PatientBridge.fhirAddress, auth, media);
                                    string lateralityString  = FHIRUtilities.LateralityToString(Laterality);
                                    string captureSiteString = FHIRUtilities.CaptureSiteToString(CaptureSite);
#if NAVIGATE
                                    string output = lateralityString + " " + captureSiteString + " fingerprint accepted. Score = " + _minutiaCaptureController.BestScore + ", Fingerprint sent to server: Response = " + dataTransport.ResponseText;
                                    DisplayOutput(output);
#endif
                                    if (dataTransport.ResponseText.ToLower().Contains("error") == true || dataTransport.ResponseText.ToLower().Contains("index") == true)
                                    {
                                        string message = "Critical Identity Error Occured In Fingerprint Capture method. Please contact your adminstrator: " + dataTransport.ResponseText + " Error code = 909";
                                        MessageBox.Show(message);
                                        browser.GetMainFrame().ExecuteJavaScriptAsync("pageRefresh();");
                                        return;
                                    }
                                    if (dataTransport.ResponseText.ToLower().Contains(@"noid://") == true)
                                    {
                                        // Match found, inform JavaScript that this is an returning patient for Identity.
                                        PatientBridge.PatientFHIRProfile.LocalNoID  = dataTransport.ResponseText;                                         //save the localNoID
                                        PatientBridge.PatientFHIRProfile.NoIDStatus = "Pending";
                                        browser.GetMainFrame().ExecuteJavaScriptAsync("showIdentity('" + PatientBridge.PatientFHIRProfile.LocalNoID + "');");
                                    }
                                    else if (dataTransport.ResponseText.ToLower() == "pending")
                                    {
                                        MessageBox.Show("You are already checked in.  If you believe this is an error, please contact staff");
                                        browser.GetMainFrame().ExecuteJavaScriptAsync("pageRefresh();");
                                        return;
                                    }
                                    else
                                    {
                                        if (PatientBridge.hasValidLeftFingerprint == true)
                                        {
                                            if (MatchLeftAndRight() == true)
                                            {
                                                MessageBox.Show("Both right and left capture sites are the same.  Please start over.");
                                                browser.GetMainFrame().ExecuteJavaScriptAsync("pageRefresh();");
                                                return;
                                            }
                                        }
                                        // Match not found, inform JavaScript the capture pair is complete and the patient can move to the next step.
                                        browser.GetMainFrame().ExecuteJavaScriptAsync("showComplete('" + Laterality.ToString() + "');");
                                        if (Laterality == FHIRUtilities.LateralitySnoMedCode.Left)
                                        {
                                            Laterality  = FHIRUtilities.LateralitySnoMedCode.Right;
                                            CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.IndexFinger;
                                            _firstMinutiaCaptureController        = _minutiaCaptureController;
                                            _minutiaCaptureController             = new MinutiaCaptureController(_minimumAcceptedMatchScore);
                                            PatientBridge.hasValidLeftFingerprint = true;
                                        }
                                        else if (Laterality == FHIRUtilities.LateralitySnoMedCode.Right)
                                        {
                                            Laterality  = FHIRUtilities.LateralitySnoMedCode.Unknown;
                                            CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.Unknown;
                                            PatientBridge.hasValidRightFingerprint = true;
                                        }
                                        fingerprintScanAttempts = 0;                                         //reset scan attempt count on successful scan
                                    }
                                }
                                else
                                {
                                    // Good fingerprint pairs not found yet.  inform JavaScript to promt the patient to try again.
                                    browser.GetMainFrame().ExecuteJavaScriptAsync("showFail('" + Laterality.ToString() + "');");
#if NAVIGATE
                                    DisplayOutput("Fingerprint NOT accepted. Score = " + _minutiaCaptureController.BestScore);
#endif
                                    currentCaptureInProcess = false;
                                    return;
                                }
                            }
                        }
                        else
                        {
                            //int testy = CaptureSite.ToString().IndexOf("Thumb");
                            if (CaptureSite.ToString().IndexOf("Thumb") == -1)
                            {
                                browser.GetMainFrame().ExecuteJavaScriptAsync("alert('You have exceeded the maximum allowed scan attempts for your " + Laterality.ToString() + " " + CaptureSite + " Lets try another finger.');");
                            }
                            fingerprintScanAttempts = 0;                             //reset scan attempt count on successful scan
                            //get next laterality and capture site. Order of precedence is left, then right. Index, middle, ring, little, thumb
                            switch (Laterality.ToString() + CaptureSite.ToString())
                            {
                            case "LeftIndexFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectLeftMiddle');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.MiddleFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Left;
                                break;

                            case "LeftMiddleFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectLeftRing');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.RingFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Left;
                                break;

                            case "LeftRingFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectLeftLittle');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.LittleFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Left;
                                break;

                            case "LeftLittleFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectLeftThumb');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.Thumb;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Left;
                                break;

                            case "LeftThumb":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("moveToRightHandScan();");
                                CaptureSite            = FHIRUtilities.CaptureSiteSnoMedCode.IndexFinger;
                                Laterality             = FHIRUtilities.LateralitySnoMedCode.Right;
                                hasLeftFingerprintScan = false;
                                break;

                            case "RightIndexFinger":
                                hasLeftFingerprintScan = _patientBridge.hasValidLeftFingerprint;
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectRightMiddle');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.MiddleFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Right;
                                break;

                            case "RightMiddleFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectRightRing');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.RingFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Right;
                                break;

                            case "RightRingFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectRightLittle');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.LittleFinger;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Right;
                                break;

                            case "RightLittleFinger":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                browser.GetMainFrame().ExecuteJavaScriptAsync("setLateralitySite('selectRightThumb');");
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.Thumb;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Right;
                                break;

                            case "RightThumb":
                                attemptedScannedFingers.Add(Laterality.ToString() + CaptureSite.ToString());
                                hasRightFingerprintScan   = false;
                                _minutiaCaptureController = null;
                                if (hasLeftFingerprintScan == false)
                                {
                                    _firstMinutiaCaptureController = null;
                                }
                                CaptureSite = FHIRUtilities.CaptureSiteSnoMedCode.Unknown;
                                Laterality  = FHIRUtilities.LateralitySnoMedCode.Unknown;
                                browser.GetMainFrame().ExecuteJavaScriptAsync("clickNoRightHandFingerPrint();");
                                break;

                            default:
                                break;
                            }
                            //define walk through fingers and ability to override
                        }
                    }
                    else
                    {
                        if (hasLeftFingerprintScan == true && hasRightFingerprintScan == true)
                        {
                            browser.GetMainFrame().ExecuteJavaScriptAsync("alert('You have successfully completed this step. Please proceed to the next page by clicking the NEXT button below');");
                        }
                        else
                        {
                            browser.GetMainFrame().ExecuteJavaScriptAsync("alert('Must be on the correct page to accept a fingerprint scan. Please follow the instructions on the screen.');");
                        }
#if NAVIGATE
                        DisplayOutput("Must be on the correct page to accept a fingerprint scan.");
#endif
                    }
                    currentCaptureInProcess = false;
                }
            }
            else
            {
                browser.GetMainFrame().ExecuteJavaScriptAsync("alert('Current Scan In Process. Please wait and follow the on screen instructions.');");
            }
        }
예제 #5
0
        private void OnCaptured(CaptureResult captureResult)
        {
            // Check capture quality and throw an error if poor or incomplete capture.
            if (!biometricDevice.CheckCaptureResult(captureResult))
            {
                return;
            }


            Constants.CaptureQuality quality = captureResult.Quality;
            if ((int)quality != 0)
            {
                Quality = (int)quality;
                PoorCaputure(quality, new EventArgs());
                return;
            }

            currentCapture = new SourceAFIS.Simple.Person();

            Fingerprint newFingerPrint = new Fingerprint();

            foreach (Fid.Fiv fiv in captureResult.Data.Views)
            {
                newFingerPrint.AsBitmap = ImageUtilities.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height);
            }
            currentCapture.Fingerprints.Add(newFingerPrint);
            Afis.Extract(currentCapture);
            Template tmpCurrent = newFingerPrint.GetTemplate();

            if (FingerCaptured != null)
            {
                FingerCaptured(newFingerPrint, new EventArgs());
            }
            _capturedFingerprints.Add(newFingerPrint);

            if (_minutiaCaptureController.MatchFound == false)
            {
                if (_minutiaCaptureController.AddMinutiaTemplateProbe(tmpCurrent) == true)
                {
                    // Good pair found.
                    bestFingerprint1 = newFingerPrint;
                    bestFingerprint2 = _capturedFingerprints[_minutiaCaptureController.OtherBestFingerprintItem];
                    if (NewBestMatchFound != null)
                    {
                        NewBestMatchFound(bestFingerprint2, new EventArgs());
                    }
                }
                else
                {
                    // Good fingerprint pairs not found yet.  Try again.
                    return;
                }
            }
            // Lookup minitia pair in database.
            // If found, show NoID
            // If not found, save minutia pair in database with new NoID.
            // probe is set, search database for match.
            Template Template1 = bestFingerprint1.GetTemplate();
            Template Template2 = bestFingerprint2.GetTemplate();

            MinutiaResult idFound = IdentifyFinger(tmpCurrent);

            if ((idFound != null && idFound.NoID.Length > 0))
            {
                // Fingerprint found in database
                Score = idFound.Score;
                if (DatabaseMatchFound != null)
                {
                    DatabaseMatchFound(newFingerPrint, new EventArgs());
                }
                if (NoID.Length == 0)
                {
                    NoID = idFound.NoID;
                }
                else if (NoID.Length > 0 && NoID != idFound.NoID)
                {
                    //critical error! create false assert here.
                    NoID = idFound.NoID;
                    if (DatabaseMatchError != null)
                    {
                        DatabaseMatchError(newFingerPrint, new EventArgs());
                    }
                }
            }
            else
            {
                // Not found in database
                Score = 0;
                if (DoesNotMatch != null)
                {
                    DoesNotMatch(newFingerPrint, new EventArgs());
                }

                if (NoID.Length == 0)
                {
                    Template1.NoID.LocalNoID = Guid.NewGuid().ToString();
                    Template2.NoID           = Template1.NoID;
                    dbMinutia.AddTemplate(Template1);
                    dbMinutia.AddTemplate(Template2);
                    // trigger event NewPatientAdded
                }
            }
        }
예제 #6
0
        private void OnCaptured(CaptureResult captureResult)
        {
            // Check capture quality and throw an error if bad.
            if (!biometricDevice.CheckCaptureResult(captureResult))
            {
                return;
            }

            bool  match = false;
            float score = 0;

            Afis.Threshold = 70;

            currentCapture = new SourceAFIS.Simple.Person();

            Fingerprint newFingerPrint = new Fingerprint();

            foreach (Fid.Fiv fiv in captureResult.Data.Views)
            {
                newFingerPrint.AsBitmap = ImageUtilities.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height);
            }
            currentCapture.Fingerprints.Add(newFingerPrint);
            Afis.Extract(currentCapture);
            Template tmpCurrent = newFingerPrint.GetTemplate();

            if (!(bestCapture == null))
            {
                score = Afis.Verify(currentCapture, bestCapture);
                match = (score > Afis.Threshold);
            }
            else if ((bestCapture == null) && !(previousCapture == null))
            {
                score = Afis.Verify(currentCapture, previousCapture);
                match = (score > Afis.Threshold);
            }

            if (FingerCaptured != null)
            {
                FingerCaptured(tmpCurrent, new EventArgs());
            }

            if (match)
            {
                Template tmp;
                if (!(bestCapture == null))
                {
                    tmp = bestCapture.Fingerprints[0].GetTemplate();
                    if (tmpCurrent.Minutiae.Length >= tmp.Minutiae.Length)
                    {
                        bestCapture = currentCapture;
                    }
                }
                else if (!(previousCapture == null))
                {
                    tmp = previousCapture.Fingerprints[0].GetTemplate();
                    if (tmp.Minutiae.Length > tmpCurrent.Minutiae.Length)
                    {
                        bestCapture = previousCapture;
                    }
                    else
                    {
                        bestCapture = currentCapture;
                    }
                }

                tmp = bestCapture.Fingerprints[0].GetTemplate();


                MinutiaResult idFound = IdentifyFinger(tmp);
                if ((fGoodPairFound == false) && (patientNoID.NoID.Length == 0) && (idFound.NoID.Length == 0))
                {
                    tmp.NoID.LocalNoID = "NoID" + nextID;
                    dbMinutia.AddTemplate(tmp);
                    patientNoID = idFound;

                    nextID++;
                }
                else if ((fGoodPairFound == true) && (patientNoID.NoID.Length > 0) && (idFound.NoID.Length == 0))
                {
                    if (DatabaseMatchError != null)
                    {
                        DatabaseMatchError(tmpCurrent, new EventArgs());
                    }
                }
                else
                {
                    if (DatabaseMatchFound != null)
                    {
                        DatabaseMatchFound(tmpCurrent, new EventArgs());
                    }
                }

                if (fGoodPairFound == false)
                {
                    fGoodPairFound = true;
                    if (GoodPairFound != null)
                    {
                        GoodPairFound(tmp, new EventArgs());
                    }
                }
            }
            previousCapture = currentCapture;
        }