Ejemplo n.º 1
0
        public bool Find(BImage sub)
        {
            if (AllOccurrences)
            {
                AllPos = _base.Matches(sub, ByColor);
                var found = AllPos.Any();
                if (found)
                {
                    FirstPos = AllPos[0];
                }

                return(found);
            }

            var found_ = _base.MatchSingle(sub, out var pos, ByColor);

            FirstPos = pos;
            return(found_);
        }
Ejemplo n.º 2
0
        public void Update(BImage img)
        {
            if (_charImages.Count == 0)
            {
                _charImages.Enqueue(img);
                return;
            }

            while (_charImages.Count >= QueueLength)
            {
                _charImages.Dequeue();
                _difference.Dequeue();
            }

            var last = _charImages.ToArray()[0];
            var diff = (int)(img.Dist2(last) / (img.H * img.W));

            _charImages.Enqueue(img);
            _difference.Enqueue(diff);

            Update();
        }
Ejemplo n.º 3
0
        public static bool MatchSingle(this BImage baseImg, BImage partImg, out Pixel pos, Color?byColor = null)
        {
            pos = new Pixel();

            var bw = baseImg.W;
            var bh = baseImg.H;

            var pw = partImg.W;
            var ph = partImg.H;

            for (var j = 0; j < bh - ph + 1; j++)
            {
                for (var i = 0; i < bw - pw + 1; i++)
                {
                    pos = Pixel.Create(j, i);
                    if (baseImg.Check(partImg, pos, byColor))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
 public SubImageFinder(BImage baseImg)
 {
     _base = baseImg;
 }