public VisualCortex()
        {
            saveStopwatch = new High_Performance_Timer.Stopwatch();
            //try
            //{
            //    desktopDuplicator = new DesktopDuplicator(0);
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.ToString());
            //}
            initializeDetectionManager();
            loadDetectionImages();


            string dir = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

            if (IsTest)
            {
                testImage = new Bitmap(Image.FromFile(Path.Combine(dir, testImageName)));
            }

            //int width = desktopDuplicator.getFrameWidth();
            //int height = desktopDuplicator.getFrameHeight();
            //Image processing

            //Console.WriteLine("Detection Width: " + width);
            //Console.WriteLine("Detection Height: " + height);
        }
예제 #2
0
        public ArtificialIntelligence(UserInterface userInterface, VisualCortex visualCortex)
        {
            if (logicTimer != null)
            {
                logicTimer.Stop();
            }
            // 0 = 40fps when set to 1ms, 8fps screen, 15fps is 7.5fps
            // 1 = 65fps when set to 1ms, 8fps screen, 40fps is 8fps
            // 2 = 1000fps when set to 1ms, 6 fps screen, 60fps is 6.35 fps
            // 3 = 1000fps when set to 1ms, 7.5 fps screen, 60fps is 7.65 fps, 200fps is 8fps
            logicTimer = new ATimer(3, 1, new ATimer.ElapsedTimerDelegate(() => { logic(); }));



            this.userInterface = userInterface;
            this.visualCortex  = visualCortex;

            timerPerformanceStopwatch         = new High_Performance_Timer.Stopwatch();
            screenCapturePerformanceStopWatch = new High_Performance_Timer.Stopwatch();

            basicAI   = new BasicAI();
            autoQueue = new AutoQueueManager();

            logicTimer.Start();
        }
        public void runTest()
        {
            System.Drawing.Rectangle boundsRect = new System.Drawing.Rectangle(0, 0, testImage.Width, testImage.Height);
            var bitmapData    = testImage.LockBits(boundsRect, ImageLockMode.WriteOnly, testImage.PixelFormat);
            var bitmapPointer = bitmapData.Scan0;

            High_Performance_Timer.Stopwatch performanceWatch = new High_Performance_Timer.Stopwatch();

            unsafe
            {
                processDetection((byte *)bitmapPointer.ToPointer(), testImage.Width, testImage.Height);
            }


            testImage.UnlockBits(bitmapData);

            //Console.WriteLine("Elapsed milliseconds: {0}", performanceWatch.DurationInMilliseconds());
            //Console.WriteLine("Elapsed fps: {0}", 1000.0 / (performanceWatch.DurationInMilliseconds() / 10000.0));
            count++;
            total += performanceWatch.DurationInMilliseconds();
            //Console.WriteLine("Average milliseconds: {0}", total / count);
            //Console.WriteLine("Average fps: {0}", 1000.0 / (total  / count));
        }