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