コード例 #1
0
        public void DetectField(Canvas source, ref Canvas field, EntityTemplates objects, Frame frame, bool isEdge, bool isTitle, bool isBg)
        {
            var sw = new Stopwatch();

            sw.Start();
            Detector detector = new Detector(source);

            detector.Search();
            List <IEntity> images = detector.GetImages();

            Comparator comparator = new Comparator();

            field.Children.Clear();
            foreach (var item in images)
            {
                string title = comparator.TryDetect(objects, item.Image);
                if (title != null)
                {
                    frame.Inscription.SetTitle(title);
                    field.Children.Add(frame.GetFrame(item.Thickness, isBg, isEdge, isTitle, item.Size));
                }
            }
            sw.Stop();
            long f = sw.ElapsedMilliseconds;
        }
コード例 #2
0
ファイル: Comparator.cs プロジェクト: Konversys/ObjTracking
        /// <summary>
        /// Сравнить изображение с предполагаемым шаблоном
        /// </summary>
        /// <param name="objects">Список шаблонов</param>
        /// <param name="image">Изображение</param>
        /// <returns></returns>
        public string TryDetect(EntityTemplates objects, BitmapImage image)
        {
            IIterator iterator = objects.CreateNumerator();

            foreach (var item in iterator.GetPatterns())
            {
                if (Compare(image, item.Template))
                {
                    return(item.Title);
                }
            }
            return(null);
        }