Пример #1
0
        public EdgeHash(Template template, EdgeLookup lookup)
        {
            EdgeLookup = lookup;
            var edgeConstructor = new EdgeConstructor();

            for (int referenceMinutia = 0; referenceMinutia < template.Minutiae.Length; ++referenceMinutia)
            {
                for (int neighborMinutia = 0; neighborMinutia < template.Minutiae.Length; ++neighborMinutia)
                {
                    if (referenceMinutia != neighborMinutia)
                    {
                        var edge = new IndexedEdge()
                        {
                            Shape    = edgeConstructor.Construct(template, referenceMinutia, neighborMinutia),
                            Location = new EdgeLocation(referenceMinutia, neighborMinutia)
                        };
                        foreach (var hash in lookup.HashCoverage(edge.Shape))
                        {
                            object             value;
                            List <IndexedEdge> list;
                            if (!Hash.TryGetValue(hash, out value))
                            {
                                Hash[hash] = edge;
                            }
                            else
                            {
                                list = value as List <IndexedEdge>;
                                if (list == null)
                                {
                                    Hash[hash] = list = new List <IndexedEdge>(1);
                                    list.Add((IndexedEdge)value);
                                }
                                list.Add(edge);
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        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;
                                }
                            }
                        }
                    }
                }
            }
        }