public IEnumerable<MinutiaPair> GetFilteredRoots(ProbeIndex probeIndex, Template candidateTemplate, Predicate<EdgeShape> shapeFilter) { if (LookupCounter >= MaxEdgeLookups) yield break; var edgeConstructor = new EdgeConstructor(); for (int step = 1; step < candidateTemplate.Minutiae.Length; ++step) for (int pass = 0; pass < step + 1; ++pass) for (int candidateReference = pass; candidateReference < candidateTemplate.Minutiae.Length; candidateReference += step + 1) { int candidateNeighbor = (candidateReference + step) % candidateTemplate.Minutiae.Length; var candidateEdge = edgeConstructor.Construct(candidateTemplate, candidateReference, candidateNeighbor); if (shapeFilter(candidateEdge)) { for (var match = HashLookup.Select(candidateEdge); match != null; match = HashLookup.Next()) { var pair = new MinutiaPair(match.Location.Reference, candidateReference); if (Logger.IsActive) Logger.Log(pair); yield return pair; ++LookupCounter; if (LookupCounter >= MaxEdgeLookups) yield break; } } } }
public void Reset(MinutiaPair root) { for (int i = 0; i < PairCount; ++i) { CandidateIndex[PairList[i].Pair.Candidate] = null; ProbeIndex[PairList[i].Pair.Probe] = null; PairList[i].SupportingEdges = 0; } CandidateIndex[root.Candidate] = ProbeIndex[root.Probe] = PairList[0]; PairList[0].Pair = root; PairCount = 1; }
public float Match(Template candidate) { PrepareCandidate(candidate); int rootIndex = 0; int triangleIndex = 0; float bestScore = 0; MinutiaPair bestRoot = new MinutiaPair(); int bestRootIndex = -1; foreach (MinutiaPair root in RootSelector.GetRoots(Probe, candidate)) { float score = TryRoot(root, candidate); if (score > bestScore) { bestScore = score; bestRoot = root; bestRootIndex = rootIndex; } ++rootIndex; if (rootIndex >= MaxTriedRoots) break; if (Pairing.Count >= 3) { ++triangleIndex; if (triangleIndex >= MaxTriedTriangles) break; } } Logger.Log("Score", bestScore); Logger.Log("BestRootIndex", bestRootIndex); if (bestScore > 0 && Logger.IsActive) { Pairing.Reset(bestRoot); BuildPairing(candidate); Logger.Log("BestRoot", bestRoot); Logger.Log("BestPairing", Pairing); } return bestScore; }
float TryRoot(MinutiaPair root, Template candidate) { Pairing.Reset(root); BuildPairing(candidate); MatchAnalysis.Analyze(Pairing, EdgeLookup, Probe.Template, candidate); return MatchScoring.Compute(MatchAnalysis); }
public EdgePair(MinutiaPair reference, MinutiaPair neighbor) { Reference = reference; Neighbor = neighbor; }