示例#1
0
 public PatternFinder(String basePath, Image <Bgr, byte> source, Props props, ItemDictionary dictionary)
 {
     this.props      = props;
     this.source     = source;
     this.basePath   = basePath;
     this.dictionary = dictionary;
 }
示例#2
0
        private static Point FindPosZero(Image <Bgr, byte> source, ItemDictionary dictionary)
        {
            using (Image <Gray, float> result = source.MatchTemplate(dictionary.ForPositioning, TemplateMatchingType.CcorrNormed))
            {
                double[] minValues, maxValues;
                Point[]  minLocations, maxLocations;
                result.MinMax(out minValues, out maxValues, out minLocations, out maxLocations);

                return(new Point((int)(maxLocations[0].X - FRAME_EXTEND / 2), (int)((maxLocations[0].Y + dictionary.ForPositioning.Height) - FRAME_EXTEND / 2)));
            }
        }
示例#3
0
        public void Dump()
        {
            var source = OpenCvHelpers.CaptureScreen();
            var path   = config.ImagesDirectory + "/";
            var dict   = new ItemDictionary(path);

            if (props == null)
            {
                props = new Props(source, dict);
            }
            var offset = new TabOffset();

            offset.UpdateOffsets(config.TabIndices);

            var pf = new PatternFinder(path, source, props, dict);

            var result = pf.DoSearch();

            for (int i = 0; i < 15; ++i)
            {
                kb.Send(Keys.Left);
            }

            int currentIndex = 0;

            kb.SendDown(Keys.LControlKey);
            foreach (var items in dict.All)
            {
                if (items.Type == ItemType.Empty || items.Type == ItemType.Unknown)
                {
                    continue;
                }
                for (int x = 0; x < Props.X_COUNT - 1; ++x)
                {
                    for (int y = 0; y < Props.Y_COUNT; ++y)
                    {
                        if (result[x, y] == items.Type)
                        {
                            //move it here so we do not do select if we did not have any items in stash
                            currentIndex = SelectTab(currentIndex, offset.GetOffset(items.Type));

                            var pos = props.TranslateToImage(x + 1, y + 1);
                            mouse.MouseLeftClick(pos.X, pos.Y);
                        }
                    }
                }
            }
            kb.SendUp(Keys.LControlKey);
        }
示例#4
0
 public Props(Image <Bgr, byte> source, ItemDictionary dictionary)
 {
     PosZero = FindPosZero(source, dictionary);
 }