public double Match(FingerprintTemplate candidate) { const int maxTriedRoots = 70; const int maxTriedTriangles = 7538; Candidate = candidate; int rootIndex = 0; int triangleIndex = 0; double bestScore = 0; foreach (MinutiaPair root in GetRoots()) { double score = TryRoot(root); if (score > bestScore) { bestScore = score; } ++rootIndex; if (rootIndex >= maxTriedRoots) { break; } if (PairCount >= 3) { ++triangleIndex; if (triangleIndex >= maxTriedTriangles) { break; } } } return(bestScore); }
static Dictionary <int, List <IndexedEdge> > BuildEdgeHash(FingerprintTemplate template) { var map = new Dictionary <int, List <IndexedEdge> >(); for (int reference = 0; reference < template.Minutiae.Length; ++reference) { for (int neighbor = 0; neighbor < template.Minutiae.Length; ++neighbor) { if (reference != neighbor) { var edge = new IndexedEdge(template.Minutiae, reference, neighbor); foreach (int hash in ShapeCoverage(edge)) { List <IndexedEdge> list; if (!map.TryGetValue(hash, out list)) { map[hash] = list = new List <IndexedEdge>(); } list.Add(edge); } } } } // https://sourceafis.machinezoo.com/transparency/edge-hash FingerprintTransparency.Current.LogEdgeHash(map); return(map); }
public EdgeShape(FingerprintTemplate template, int reference, int neighbor) { var vector = template.Minutiae[neighbor].Position - template.Minutiae[reference].Position; int quadrant = 0; int x = vector.X; int y = vector.Y; if (y < 0) { x = -x; y = -y; quadrant = 128; } if (x < 0) { int tmp = -x; x = y; y = tmp; quadrant += 64; } int shift = MathEx.HighestBit((uint)(x | y) >> PolarCacheBits); Length = PolarDistance[y >> shift, x >> shift] << shift; var angle = (byte)(PolarAngle[y >> shift, x >> shift] + quadrant); ReferenceAngle = Angle.Difference(template.Minutiae[reference].Direction, angle); NeighborAngle = Angle.Difference(template.Minutiae[neighbor].Direction, Angle.Opposite(angle)); }
public void SelectCandidate(FingerprintTemplate template) { Candidate = template; if (ByCandidate.Length < Candidate.Minutiae.Length) { ByCandidate = new MinutiaPair[Candidate.Minutiae.Length]; } }
public FingerprintMatcher(FingerprintTemplate probe) { if (probe == null) { throw new ArgumentNullException(nameof(probe)); } Template = probe; EdgeHash = BuildEdgeHash(probe); }
public void SelectMatcher(FingerprintMatcher matcher) { Probe = matcher.Template; if (Probe.Minutiae.Length > Tree.Length) { Tree = new MinutiaPair[Probe.Minutiae.Length]; ByProbe = new MinutiaPair[Probe.Minutiae.Length]; } EdgeHash = matcher.EdgeHash; }
public FingerprintMatcher(FingerprintTemplate template) { Template = template; BuildEdgeHash(); PairsByProbe = new PairInfo[Template.Minutiae.Count]; PairList = new PairInfo[Template.Minutiae.Count]; for (int i = 0; i < PairList.Length; ++i) { PairList[i] = new PairInfo(); } }
public double Match(FingerprintTemplate candidate) { if (candidate == null) { throw new ArgumentNullException(nameof(candidate)); } var thread = MatcherThread.Current; thread.SelectMatcher(this); thread.SelectCandidate(candidate); return(thread.Match()); }