Пример #1
0
 /// <summary>
 /// Steps through all available temmplates and match fingerprint templates
 /// </summary>
 /// <param name="comparer">Delegate function that does the actual matching in the context desgnated by a particular finger</param>
 /// <param name="matchAny">If true any one finger match is sufficient for matching, if false all fingers must match</param>
 /// <param name="fingerContexts">List of matching contexts indexed by finger</param>
 /// <param name="matchFingers">Flags of fingers available for matching</param>
 /// <returns></returns>
 public object Identify(CompareFingerDelegate comparer, bool matchAny, Dictionary <Fingers, int> fingerContexts, Fingers matchFingers)
 {
     if (Connection != null && Connection.State == ConnectionState.Open)
     {
         using (IDataReader rdr = InternalGetTemplates()) //Reader must be sorted by individual
         {
             Fingers             matchedFingers = 0;      //fingers that have been matched
             FingerprintTemplate template;
             Fingers             finger;
             while (rdr.Read())
             {
                 ReadTemplate(rdr, out finger, out template);
                 if ((matchFingers & finger) != 0)
                 {
                     if (comparer(fingerContexts[finger], template))
                     {
                         matchedFingers |= finger;
                     }
                 }
                 if ((matchAny & ((matchFingers & matchedFingers) != 0)) | (matchFingers == matchedFingers)) //individual matched
                 {
                     return(rdr[IndividualFieldName]);
                 }
             } //while
             return(null); //No match found
         }
     }
     else
     {
         throw new FPLibraryException(FPLibraryException.LibraryDalError, "Connection is null or closed");
     }
 }
Пример #2
0
 /// <summary>
 /// Fingerprints are obtained, first tested if they exist in the database, and if not then saved to the database
 /// The individual to which the captured fingerprints must be saved must be set as the ActiveIndividual in the DataAccesLayer
 /// </summary>
 /// <param name="sensor">The sensor to capture the finger print from</param>
 /// <returns>The individual ID of the individual identified, null if none was identified</returns>
 public object IdentifyAndCapture(string sensor)
 {
     try
     {
         object result = null;
         griauleLibrary.SetIdentifyParameters(IdentificationThreshold, IdentificationRotationTolerance);
         Dictionary <Fingers, FingerprintTemplate> capturedFingers = Capture(sensor, DataAccessLayer.ActiveIndividual != null);
         if (capturedFingers != null && capturedFingers.Count > 0)
         {
             //Set up and prepare an identification context for each captured finger
             Dictionary <Fingers, int> fingerContexts = new Dictionary <Fingers, int>(capturedFingers.Count);
             Fingers matchFingers = 0; //Fingers to match
             try
             {
                 foreach (var kvp in capturedFingers)
                 {
                     int context;
                     griauleLibrary.CreateContext(out context);
                     fingerContexts.Add(kvp.Key, context);
                     griauleLibrary.IdentifyPrepare(capturedFingers[kvp.Key], context);
                     matchFingers |= kvp.Key; //add finger to fingers to be matched
                 }
                 CompareFingerDelegate comparer = CompareTemplate;
                 result = DataAccessLayer.Identify(CompareTemplate, true, fingerContexts, matchFingers);
                 if (result == null) //No one identified
                 {
                     foreach (var kvp in capturedFingers)
                     {
                         DataAccessLayer.SaveTemplate(kvp.Key, kvp.Value);
                     }
                 }
             }
             finally
             {
                 foreach (var kvp in fingerContexts)
                 {
                     griauleLibrary.DestroyContext(kvp.Value);
                 }
             }
         }
         return(result);
     }
     catch (FingerprintException ex)
     {
         MessageBox.Show(String.Format("Identification Error : {0} {1}", ex.ErrorCode, ex.Message), "FPLibrary Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(null);
     }
     catch (Exception e)
     {
         MessageBox.Show(String.Format("Identification Error : {0}", e.Message), "FPLibrary Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(null);
     }
 }
Пример #3
0
 /// <summary>
 /// Steps through all available temmplates and match fingerprint templates
 /// </summary>
 /// <param name="comparer">Delegate function that does the actual matching in the context desgnated by a particular finger</param>
 /// <param name="matchAny">If true any one finger match is sufficient for matching, if false all fingers must match</param>
 /// <param name="fingerContexts">List of matching contexts indexed by finger</param>
 /// <param name="matchFingers">Flags of fingers available for matching</param>
 /// <returns></returns>
 public object Identify(CompareFingerDelegate comparer, bool matchAny, Dictionary<Fingers, int> fingerContexts, Fingers matchFingers)
 {
     if (Connection != null && Connection.State == ConnectionState.Open)
       {
     using (IDataReader rdr = InternalGetTemplates()) //Reader must be sorted by individual
     {
       Fingers matchedFingers = 0; //fingers that have been matched
       FingerprintTemplate template;
       Fingers finger;
       while (rdr.Read())
       {
     ReadTemplate(rdr, out finger, out template);
     if ((matchFingers & finger) != 0)
     {
       if (comparer(fingerContexts[finger], template))
         matchedFingers |= finger;
     }
     if ((matchAny & ((matchFingers & matchedFingers) != 0)) | (matchFingers == matchedFingers)) //individual matched
       return rdr[IndividualFieldName];
       } //while
       return null; //No match found
     }
       }
       else
       {
     throw new FPLibraryException(FPLibraryException.LibraryDalError, "Connection is null or closed");
       }
 }