/// <summary> /// Compute similarity score between two <see cref="Person"/>s. /// </summary> /// <param name="probe">First of the two persons to compare.</param> /// <param name="candidate">Second of the two persons to compare.</param> /// <returns>Similarity score indicating similarity between the two persons or 0 if there is no match.</returns> /// <remarks> /// <para> /// <see cref="Verify"/> method compares two <see cref="Person"/>s, <see cref="Fingerprint"/> by <see cref="Fingerprint"/>, and returns /// floating-point similarity score that indicates degree of similarity between /// the two <see cref="Person"/>s. If this score falls below <see cref="Threshold"/>, <see cref="Verify"/> method returns zero. /// </para> /// <para> /// <see cref="Person"/>s passed to this method must have valid <see cref="Fingerprint.Template"/> /// for every <see cref="Fingerprint"/>, i.e. they must have passed through <see cref="Extract"/> method. /// </para> /// </remarks> /// <seealso cref="Threshold"/> /// <seealso cref="MinMatches"/> /// <seealso cref="Identify"/> public float Verify(Person probe, Person candidate) { lock (this) { probe.CheckForNulls(); candidate.CheckForNulls(); BestMatchSkipper collector = new BestMatchSkipper(1, MinMatches - 1); Parallel.ForEach(probe.Fingerprints, probeFp => { var candidateTemplates = (from candidateFp in candidate.Fingerprints where IsCompatibleFinger(probeFp.Finger, candidateFp.Finger) select candidateFp.Decoded).ToList(); ParallelMatcher.PreparedProbe probeIndex = Matcher.Prepare(probeFp.Decoded); float[] scores = Matcher.Match(probeIndex, candidateTemplates); lock (collector) foreach (float score in scores) { collector.AddScore(0, score); } }); return(ApplyThreshold(collector.GetSkipScore(0))); } }
void Collect(Template probe, Template candidate) { if (probe != null && candidate != null) { ParallelMatcher.PreparedProbe prepared = Matcher.Prepare(probe); Matcher.Match(prepared, new Template[] { candidate }); } Logs = Logger.PopLog(); }
public bool UpdateTemplate(Template newBest, string NoID) { string _NoID = ""; float[] scores; bool result = false; try { lock (this) { ParallelMatcher Matcher = new ParallelMatcher(); ParallelMatcher.PreparedProbe probeIndex = Matcher.Prepare(newBest); scores = Matcher.Match(probeIndex, _fingerPrintCandidateList); if (scores.Length > 0) { for (int i = 0; i < scores.Count(); i++) { if (scores[i] > _matchThreshold) { _NoID = _fingerPrintCandidateList[i].NoID.LocalNoID; if (_NoID == NoID) { newBest.NoID.LocalNoID = _NoID; _fingerPrintCandidateList[i] = newBest; break; } } } } } result = true; } catch (Exception ex) { _exception = ex; } return(result); }
void RunPrepare(Template template, Stopwatch timer) { timer.Start(); PreparedProbe = Matcher.Prepare(template); timer.Stop(); }