public void TestV1(string file1, string file2, bool match) { const string resPrefix = "BananoMonkeyMatchEmulator.samples.v1_june2018."; using (var stream1 = Assembly.GetExecutingAssembly().GetManifestResourceStream(resPrefix + file1)) { using (var stream2 = Assembly.GetExecutingAssembly().GetManifestResourceStream(resPrefix + file2)) { using (var image1 = Image.FromStream(stream1)) { using (var image2 = Image.FromStream(stream2)) { var equal = ImageComparer.AreEqual(image1, image2, out var similarity); Assert.Equal(match, equal); } } } } }
public async Task <int> FindMatchAsync(string prefix, string expected, string[] candidates) { var url = prefix + expected; using (var img = Image.FromStream(await secondaryHttpClient.GetStreamAsync(prefix + expected))) { for (var i = 0; i < candidates.Length; i++) { using (var cand = Image.FromStream(await secondaryHttpClient.GetStreamAsync(prefix + candidates[i]))) { var match = ImageComparer.AreEqual(img, cand, out var similarity); logger.LogDebug($"Compare {expected} with {candidates[i]}: {similarity}{(match ? " MATCH" : string.Empty)}"); if (match) { return(i); } } } } return(-1); }