public void Test(Bitmap image, Bitmap template, IEnumerable<Point> expected) { var searcher = new BitmapSearcher(template, (SimpleColor)Color.Black); searcher.Learn(image, expected.Count()); var actual = searcher.GetPositions(image).ToArray(); Assert.That(actual, Is.EquivalentTo(expected)); }
/// <exception cref="System.Runtime.SerializationException"></exception> public static void Serialize(BitmapSearcher obj, Stream output) { try { using (var memory = new MemoryStream()) { formatter.WriteObject(memory, obj); memory.WriteTo(output); } } catch (System.Exception e) { throw new System.Runtime.Serialization.SerializationException("Unknown", e); } }
public ConcurrentSearcher(BitmapSearcher searcher) { _locker = new object(); _lastVersion = searcher; InitializeEmptyTask(); }
/// <exception cref="System.ArgumentException"></exception> /// <exception cref="System.ArgumentNullException"></exception> public void Add(string id, Bitmap template) { if (id == null) throw new ArgumentNullException("id"); if (template == null) throw new ArgumentNullException("template"); lock (locker) { if (simpleStore.ContainsKey(id)) throw new ArgumentException("id"); var searcher = new BitmapSearcher(template, SimpleColor.FromRgb(0, 0, 0)); simpleStore[id] = new ConcurrentSearcher(searcher); } }
/// <summary> /// Объединяет результаты обучения объектов. Результат сохраняет в текущий объект. /// </summary> /// <param name="other"></param> public void UniteWith(BitmapSearcher other) { this.searcher.UniteWith(other.searcher); }