예제 #1
0
 public static byte[] Serialized(SampleFingerprint fp)
 {
     return(PersistentCache.Get("templates", fp.Path + ".cbor", () =>
     {
         return new FingerprintTemplate(fp.Decode()).ToByteArray();
     }));
 }
예제 #2
0
 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));
     }));
 }
예제 #3
0
 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];
         }
     }));
 }
예제 #4
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();
         }
     }));
 }
예제 #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;
     }));
 }
예제 #6
0
 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();
         }
     }));
 }
예제 #7
0
 static string ExtractorPath(string key, SampleFingerprint fp)
 {
     return(fp.Path + Extension(TransparencyStats.ExtractorRow(fp, key).Mime));
 }
예제 #8
0
 public static FingerprintTemplate Of(SampleFingerprint fp)
 {
     return(new FingerprintTemplate(Serialized(fp)));
 }
예제 #9
0
 public static TransparencyStats ExtractorRow(SampleFingerprint fp, String key)
 {
     return(ExtractorTable(fp).Rows.Where(r => r.Key == key).First().Stats);
 }
예제 #10
0
 public static T Get <T>(string category, SampleFingerprint fp, Func <T> supplier)
 {
     return(Get <T>(category, Path.Combine(fp.Dataset.Name, fp.Name), supplier));
 }