public static byte[] ExtractorNormalized(string key, SampleFingerprint fp)
 {
     return(PersistentCache.Get(Path.Combine("normalized-extractor-transparency-files", key), ExtractorPath(key, fp), () =>
     {
         return SerializationUtils.Normalize(TransparencyStats.ExtractorRow(fp, key).Mime, Extractor(key, fp));
     }));
 }
 public static byte[] Serialized(SampleFingerprint fp)
 {
     return(PersistentCache.Get("templates", fp.Path + ".cbor", () =>
     {
         return new FingerprintTemplate(fp.Decode()).ToByteArray();
     }));
 }
 public static byte[] Extractor(string key, SampleFingerprint fp)
 {
     return(PersistentCache.Get(Path.Combine("extractor-transparency-files", key), ExtractorPath(key, fp), () =>
     {
         using (var collector = new FileCollector(key))
         {
             new FingerprintTemplate(fp.Decode());
             return collector.Files[0];
         }
     }));
 }
 public static Table ExtractorTable(SampleFingerprint fp)
 {
     return(PersistentCache.Get <Table>("extractor-transparency-stats", fp.Path, () =>
     {
         using (var collector = new TableCollector())
         {
             new FingerprintTemplate(fp.Decode());
             return collector.Sum();
         }
     }));
 }
Beispiel #5
0
 public static TemplateFootprint Of(SampleFingerprint fp)
 {
     return(PersistentCache.Get("footprints", fp.Path, () =>
     {
         var footprint = new TemplateFootprint();
         var serialized = NativeTemplate.Serialized(fp);
         footprint.Count = 1;
         footprint.Serialized = serialized.Length;
         footprint.Hash = DataHash.Of(SerializationUtils.Normalize(serialized));
         return footprint;
     }));
 }
 public static Table ExtractorTable(SampleFingerprint fp)
 {
     return(PersistentCache.Get <Table>("extractor-transparency-stats", fp, () =>
     {
         var image = fp.Load();
         using (var collector = new TableCollector())
         {
             new FingerprintTemplate(fp.Decode());
             return collector.Accumulator.Summarize();
         }
     }));
 }
 public static ScalarAccuracy Of(SampleDataset dataset)
 {
     return(PersistentCache.Get("accuracy", dataset.Path, () =>
     {
         var trio = QuantileFunction.Of(dataset);
         var accuracy = new ScalarAccuracy();
         accuracy.Fmr100 = QuantileFunction.FnmrAtFmr(trio.Matching, trio.Nonmatching, 1.0 / 100);
         accuracy.Fmr1K = QuantileFunction.FnmrAtFmr(trio.Matching, trio.Nonmatching, 1.0 / 1_000);
         accuracy.Fmr10K = QuantileFunction.FnmrAtFmr(trio.Matching, trio.Nonmatching, 1.0 / 10_000);
         accuracy.Eer = QuantileFunction.Eer(trio.Matching, trio.Nonmatching);
         return accuracy;
     }));
 }
Beispiel #8
0
 public static double[][] Of(SampleDataset dataset)
 {
     return(PersistentCache.Get("scores", dataset.Path, () =>
     {
         var fingerprints = dataset.Fingerprints;
         var templates = fingerprints.Select(fp => NativeTemplate.Of(fp)).ToList();
         var scores = new double[fingerprints.Count][];
         foreach (var probe in fingerprints)
         {
             var matcher = new FingerprintMatcher(templates[probe.Id]);
             scores[probe.Id] = new double[fingerprints.Count];
             foreach (var candidate in fingerprints)
             {
                 scores[probe.Id][candidate.Id] = matcher.Match(templates[candidate.Id]);
             }
         }
         return scores;
     }));
 }