Beispiel #1
0
            public CardPipeline(TableLayout layout)
            {
                // patterns
                List <CardPattern> patterns = CardReader.readCardsFromResources();
                CardStrategy       strategy = new CardStrategyFast(patterns, layout);

                this.identifier = new CardIdentifier(strategy.identifyRegions,
                                                     strategy.identifyCards);
            }
Beispiel #2
0
            public CardPipelineSlow()
            {
                // patterns
                List <CardPattern> patterns = CardReader.readCardsFromResources();
                CardStrategy       strategy = new CardStrategySlow(patterns);

                this.identifier = new CardIdentifier(strategy.identifyRegions,
                                                     strategy.identifyCards);
            }
Beispiel #3
0
        public static void Main(string[] args)
        {
            Log.SetLevel(Log.Level.FINEST);

            // patterns
            List <CardPattern> patterns = CardReader.readCardsFromResources();

            Console.WriteLine("read " + patterns.Count + " candidate patterns");

            // renderer
            ImagesRenderer renderer = newImageRenderer();

            // iterator
            Iterator <Image> wait;

            if (USE_SCREEN)
            {
                Thread.Sleep(10);
                TableContainer   table  = new BotAppLogic(new Win32Control()).LocateNewTable(new Settings());
                Rectangle        rect   = new Rectangle(table.Layout.Offset.X, table.Layout.Offset.Y, table.Layout.Size.Width, table.Layout.Size.Height);
                Iterator <Image> screen = new ScreenImageIterator(new Win32Control(), rect);
                wait = new WaitDeltaImageIterator(screen);
            }
            else
            {
                wait = new MockIterator(toImage(new Bitmap("test/table_no_middle_button.png")));
            }

            // proxy
            IteratorProxy <Image> proxyIter = new IteratorProxy <Image>(wait);

            proxyIter.handler += delegate(Image next)
            {
                setImage(renderer, toBitmap(next));
            };
            Console.WriteLine("initialized iterator");

            // identifier
            CardStrategy           strategy   = new CardStrategyFast(patterns, new TableLayout9());
            CardIdentifierIterator identifier = new CardIdentifierIterator(proxyIter,
                                                                           strategy.identifyRegions,
                                                                           strategy.identifyCards);

            // go
            while (identifier.hasNext())
            {
                DateTime    start = DateTime.Now;
                List <Card> cards = identifier.next();
                setText(renderer, toText(cards));
                Console.WriteLine("iteration took " + DateTime.Now.Subtract(start).TotalSeconds + "s");
                Console.ReadKey();
            }
        }
Beispiel #4
0
        public static void Main(string[] args)
        {
            Log.SetLevel(Log.Level.FINE);

            // patterns
            List <CardPattern> patterns = CardReader.readCardsFromResources();

            Console.WriteLine("read " + patterns.Count + " candidate patterns");

            // renderer
            ImagesRenderer renderer = newImageRenderer();

            // iterator
            Iterator <Image> wait;

            if (USE_SCREEN)
            {
                Iterator <Image> screen = new ScreenImageIterator(new Win32Control(), new Rectangle(400, 400, 300, 80));
                wait = new WaitDeltaImageIterator(screen);
            }
            else
            {
                wait = new MockIterator(toImage(new Bitmap("test/cards_56.png")));
            }

            Iterator <Image> low = new ReduceColorIterator(wait, new ColorReducers.Card());

            // proxy
            IteratorProxy <Image> proxyIter = new IteratorProxy <Image>(low);

            proxyIter.handler += delegate(Image next)
            {
                setImage(renderer, toBitmap(next));
            };
            Console.WriteLine("initialized iterator");

            // identifier
            CardStrategy           strategy   = new CardStrategySlow(patterns);
            CardIdentifierIterator identifier = new CardIdentifierIterator(proxyIter,
                                                                           strategy.identifyRegions,
                                                                           strategy.identifyCards);

            // go
            while (identifier.hasNext())
            {
                DateTime    start = DateTime.Now;
                List <Card> cards = identifier.next();
                setText(renderer, toText(cards));
                Console.WriteLine("iteration took " + DateTime.Now.Subtract(start).TotalSeconds + "s");
            }
        }
Beispiel #5
0
        public static void Main(string[] args)
        {
            // patterns
            List <CardPattern> patterns = CardReader.readCardsFromResources();

            Console.WriteLine("read " + patterns.Count + " candidate patterns");

            // renderer
            ImagesRenderer renderer = newImageRenderer();

            // iterator
            Iterator <Image> wait = new MockIterator(toImage(new Bitmap("hand.png")));

            //Iterator<Image> screen = new ScreenImageIterator(new Rectangle(400, 400, 300, 80));
            //Iterator<Image> wait = new WaitDeltaImageIterator(screen);
            Iterator <Image> low = new ReduceColorIterator(wait, new ColorReducers.Card());

            // proxy
            IteratorProxy <Image> proxyIter = new IteratorProxy <Image>(low);

            proxyIter.handler += delegate(Image next)
            {
                setImage(renderer, toBitmap(next));
            };
            Console.WriteLine("initialized iterator");

            // identifier
            PocketIdentifier identifier = new PocketIdentifier(patterns);

            // go
            while (proxyIter.hasNext())
            {
                Image       screen = proxyIter.next();
                DateTime    start  = DateTime.Now;
                List <Card> hand   = identifier.identifyCards(screen);
                double      ms     = DateTime.Now.Subtract(start).TotalMilliseconds;
                Console.WriteLine("identification took " + ms + "ms");
                Console.WriteLine(toText(hand));
            }
        }