Exemplo n.º 1
0
        public void FindNemoCloseTest()
        {
            var shotcBmp     = @"shotc.bmp";
            var nemoCloseBmp = @"1.bmp";

            var directoryInfo = Directory.GetParent(Directory.GetCurrentDirectory()).Parent;

            if (directoryInfo != null)
            {
                Console.WriteLine(directoryInfo.FullName);
            }
            var hayStackShotPath = Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\..\\FindImageInImage\\bin\\Debug", shotcBmp);
            var needlePath       = Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\..\\FindImageInImage\\bin\\Debug\\NemoCloses", nemoCloseBmp);

            Console.WriteLine(File.Exists(hayStackShotPath) ? $"  {hayStackShotPath} Exists" : $" {hayStackShotPath} does not Exist");
            Console.WriteLine(File.Exists(needlePath) ? $"  {needlePath} Exists" : $" {needlePath} does not Exist");
            var haystackBitmap = (Bitmap)Image.FromFile(hayStackShotPath);

            Assert.IsNotNull(haystackBitmap);

            var needleBitmap = (Bitmap)Image.FromFile(needlePath);

            Assert.IsNotNull(needleBitmap);
            var screenShotsManager = new ScreenShotsManager();
            var result             = screenShotsManager.Find(haystackBitmap, needleBitmap);

            Assert.IsNotNull(result);
            Console.WriteLine($"Needle in Haystack Found? {result}");
        }
Exemplo n.º 2
0
        public void TakeScreenShotTest()
        {
            var screenShotsManager = new ScreenShotsManager();

            Assert.IsNotNull(screenShotsManager, "ScreenShotManager could not be initialized");
            screenShotsManager.TakeScreenShot();
        }
Exemplo n.º 3
0
        public void SearchBitmapTestMegaServerErrorFindTest()
        {
            // string solution_dir = Path.GetDirectoryName(Path.GetDirectoryName(TestContext.TestDir));
            Console.WriteLine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName);
            var haystackBitmap = (Bitmap)Image.FromFile(@".\serverErrorShot.bmp");

            Assert.IsNotNull(haystackBitmap);

            var needleBitmap = (Bitmap)Image.FromFile(@".\serverError.bmp");

            Assert.IsNotNull(needleBitmap);
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var points = ImageProcessing.FindBitmapsEntry(haystackBitmap, needleBitmap, true);

            stopwatch.Stop();
            Console.WriteLine($"Image Find Took {stopwatch.ElapsedMilliseconds} milliseconds");
            Assert.IsTrue(points.Count > 0);
            points.ForEach(x => Console.WriteLine(x.ToString()));
            stopwatch.Start();
            var shotsManager = new ScreenShotsManager();
            var pt           = shotsManager.Find(haystackBitmap, needleBitmap);

            stopwatch.Stop();
            Console.WriteLine($"Image Find GetPixel way Took {stopwatch.ElapsedMilliseconds} milliseconds");
            Assert.IsTrue(pt.HasValue);
        }
Exemplo n.º 4
0
        public void ScreenShotTest()
        {
            var screenShotsManager = new ScreenShotsManager();

            Assert.IsNotNull(screenShotsManager, "ScreenShotManager could not be initialized");
            screenShotsManager.ScreenShot(-1920, 0, 1920, 1080, "../../test.bmp");
        }
Exemplo n.º 5
0
        // private List<string> words = commaWords.Split(',');
        public FindImageInScreenShot()
        {
            this.InitializeComponent();
            this.screenShotsManager  = new ScreenShotsManager();
            InterceptKeys.OnKeyDown += this.InterceptKeys_OnKeyDown;
            InterceptKeys.Start();
            InterceptMouse.OnMouseLeftButtonDown += this.InterceptMouse_OnMouseLeftButtonDown;

            InterceptMouse.Start();
        }
Exemplo n.º 6
0
 public MegaAdProcessor(
     ScreenShotsManager screenShotsManager,
     List <Bitmap> toFindBitmaps,
     List <Bitmap> closeBitmaps,
     bool fakeMoves)
 {
     this.screenShotsManager = screenShotsManager;
     this.toFindBitmaps      = toFindBitmaps;
     this.closeBitmaps       = closeBitmaps;
     this.fakeMoves          = fakeMoves;
     this.StopAllProcessing  = false;
 }
Exemplo n.º 7
0
 public void TempTest()
 {
     try
     {
         var screenShotsManager = new ScreenShotsManager();
         Assert.IsNotNull(screenShotsManager, "ScreenShotManager could not be initialized");
         screenShotsManager.TakeScreenShot();
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message + e.InnerException?.Message);
     }
 }
Exemplo n.º 8
0
        public void LoadAllBitmapsFromDirectoryTest()
        {
            // string solution_dir = Path.GetDirectoryName(Path.GetDirectoryName(TestContext.TestDir));
            Console.WriteLine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName);

            var stopwatch = new Stopwatch();

            stopwatch.Start();
            var shotsManager = new ScreenShotsManager();
            var bitmaps      = shotsManager.LoadAllBitmapsFromDirectory(".\\Cats\\");

            stopwatch.Stop();
            Console.WriteLine($"LoadAllBitmapsFromDirectory took {stopwatch.ElapsedMilliseconds} milliseconds for {bitmaps.Count} files");
        }
Exemplo n.º 9
0
        public void FindTest()
        {
            // string solution_dir = Path.GetDirectoryName(Path.GetDirectoryName(TestContext.TestDir));
            Console.WriteLine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName);
            var haystackBitmap = (Bitmap)Image.FromFile(@"testStrip2.bmp");

            Assert.IsNotNull(haystackBitmap);

            var needleBitmap = (Bitmap)Image.FromFile(@".\eyepop.bmp");

            Assert.IsNotNull(needleBitmap);
            var screenShotsManager = new ScreenShotsManager();
            var result             = screenShotsManager.Find(haystackBitmap, needleBitmap);

            Console.WriteLine(result.ToString());
        }
Exemplo n.º 10
0
 public NemoAdProcessor(
     ScreenShotsManager screenShotsManager,
     List <Bitmap> toFindBitmaps,
     List <Bitmap> clickDotBitmap,
     List <Bitmap> closeBitmaps,
     int displayIndex,
     bool fakeMoves,
     Dispatcher cd)
 {
     this.screenShotsManager = screenShotsManager;
     this.toFindBitmaps      = toFindBitmaps;
     this.clickDotBitmap     = clickDotBitmap;
     this.closeBitmaps       = closeBitmaps;
     this.fakeMoves          = fakeMoves;
     this.DisplayScreen      = DisplayIndex.GetDisplayRectangle(displayIndex);
     this.StopAllProcessing  = false;
     this.currentDispatcher  = cd;
     Logger.Info($"{MethodBase.GetCurrentMethod().Name} - Finished Initialization");
 }
Exemplo n.º 11
0
        public void SearchBitmapTestNeoUsingFindByPixelTest()
        {
            // string solution_dir = Path.GetDirectoryName(Path.GetDirectoryName(TestContext.TestDir));
            Console.WriteLine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName);
            var haystackBitmap = (Bitmap)Image.FromFile(@".\neofindAdTest.bmp");

            Assert.IsNotNull(haystackBitmap);

            var needleBitmap = (Bitmap)Image.FromFile(@".\ToFind.bmp");

            Assert.IsNotNull(needleBitmap);
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var shotsManager = new ScreenShotsManager();
            var pt           = shotsManager.Find(haystackBitmap, needleBitmap);

            stopwatch.Stop();
            Console.WriteLine($"Image Find GetPixel way Took {stopwatch.ElapsedMilliseconds} milliseconds");
            Assert.IsTrue(pt.HasValue);
        }
Exemplo n.º 12
0
        public void RenameBitmapsFromDirectoryTest()
        {
            var shotsManager = new ScreenShotsManager();

            shotsManager.RenameBitmapsFromDirectory(@"F:\Development\WPF\MyDream\FindImageInImage\bin\Debug\Cats");
        }
Exemplo n.º 13
0
        public ClixSenseAdProcessor(
            ScreenShotsManager screenShotsManager,
            List <Bitmap> toFindBitmaps,
            Dictionary <string, Bitmap> catBitmaps,
            List <Bitmap> closeBitmaps,
            int displayIndex,
            int zoomFactorX,
            int zoomFactorY,
            bool fakeMoves,
            Dispatcher cd)
        {
            this.screenShotsManager = screenShotsManager;
            this.toFindBitmaps      = toFindBitmaps;
            this.closeBitmaps       = closeBitmaps;
            this.catBitmaps         = catBitmaps;
            this.fakeMoves          = fakeMoves;
            this.zoomFactorX        = zoomFactorX;
            this.zoomFactorY        = zoomFactorY;
            this.CaptureCatImage    = false;
            this.StopAllProcessing  = false;
            this.DisplayScreen      = DisplayIndex.GetDisplayRectangle(displayIndex);
            this.clixConfig         = new ClixSenseAdProcessorConfig();
            if ((this.clixConfig = this.clixConfig.Load($".\\ClixSenseAdProcessorConfig" + ".xml")) == null)
            {
                this.clixConfig = new ClixSenseAdProcessorConfig();
                this.clixConfig.Save($".\\ClixSenseAdProcessorConfig" + ".xml");
                Logger.Info($"Saved {nameof(this.clixConfig)} correctly : {this.clixConfig}");
            }
            else
            {
                Logger.Info($"Loaded {nameof(this.clixConfig)} correctly : {this.clixConfig}");
            }

            this.currentDispatcher = cd;
            //this.TalkingCool = new Talking();
            Logger.Info($"ClickSense initialize - Trying to initialize speech ");
            try
            {
                this.installedVoices    = new List <InstalledVoice>(this.synthesizer.GetInstalledVoices());
                this.synthesizer.Volume = 100; // 0...100
                this.synthesizer.Rate   = -2;  // -10...10
                this.synthesizer.SelectVoice(this.installedVoices.First().VoiceInfo.Name);
                var numbers = new Choices();
                numbers.Add("one", "two", "three", "four", "five", "Refresh", "Close"); //, "Close"
                // Create a GrammarBuilder object and append the Choices object.
                var gb = new GrammarBuilder();
                gb.Append(new GrammarBuilder(numbers), 1, 5);
                var grammer = new Grammar(gb)
                {
                    Priority = 127
                };
                this.speechRecognitionEngine.RequestRecognizerUpdate();
                this.speechRecognitionEngine.LoadGrammar(grammer);
                this.speechRecognitionEngine.SetInputToDefaultAudioDevice();
                this.speechRecognitionEngine.SpeechRecognized          += this.SpeechRecognitionEngine_SpeechRecognized;
                this.speechRecognitionEngine.SpeechDetected            += this.SpeechRecognitionEngine_SpeechDetected;
                this.speechRecognitionEngine.SpeechRecognitionRejected += this.SpeechRecognitionEngine_SpeechRecognitionRejected;
                this.speechRecognitionEngine.RecognizeCompleted        += this.SpeechRecognitionEngine_RecognizeCompleted;
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message + exception.InnerException?.Message);
                throw exception;
            }
            Logger.Info($" Finished audio Initializer with no exceptions - found {this.installedVoices.Count} voices");
        }