Exemple #1
0
        public String SeeifAlbumsInSearchResults()
        {
            int topsize   = 30;
            int widthsize = 125;
            int left      = 265;
            int top       = 180;

            Bitmap bmp = new Bitmap(widthsize, topsize, PixelFormat.Format32bppArgb);

            using (Graphics g = Graphics.FromImage(bmp))
            {
                var rect = new User32.Rect();
                User32.GetWindowRect(FocusSpotify(true).MainWindowHandle, ref rect);

                Graphics graphics = Graphics.FromImage(bmp);
                g.CopyFromScreen(left, top, 0, 0, new Size(widthsize, topsize), CopyPixelOperation.SourceCopy);
            }

            //make it a big bigger first
            Size si = new Size(bmp.Width * 2, bmp.Height * 2); //bump up the size to increase BlueSimilarity's change of not fudging the text

            bmp = ResizeImage(bmp, si);

            bmp.Save("lastsearch.png");

            String MatchedText;

            using (var engine = new TesseractEngine("tesseract-ocr", "eng", EngineMode.Default))
            {
                using (var pix = PixConverter.ToPix(bmp))
                {
                    using (var page = engine.Process(pix))
                    {
                        //3. Get matched text from tesseract
                        MatchedText = page.GetText();
                    }
                }
            }

            String[] Lines = MatchedText.Split(new char[] { '\n' });
            String   Word  = Lines[0];

            return(Word);
        }
Exemple #2
0
        public String SeeifAlbumsInSearchResults()
        {
            int topsize = 30;
            int widthsize = 125;
            int left = 265;
            int top = 180;

            Bitmap bmp = new Bitmap(widthsize, topsize, PixelFormat.Format32bppArgb);

            using (Graphics g = Graphics.FromImage(bmp))
            {
                var rect = new User32.Rect();
                User32.GetWindowRect(FocusSpotify(true).MainWindowHandle, ref rect);

                Graphics graphics = Graphics.FromImage(bmp);
                g.CopyFromScreen(left, top, 0, 0, new Size(widthsize, topsize), CopyPixelOperation.SourceCopy);
            }

            //make it a big bigger first
            Size si = new Size(bmp.Width * 2, bmp.Height * 2); //bump up the size to increase BlueSimilarity's change of not fudging the text
            bmp = ResizeImage(bmp, si);

            bmp.Save("lastsearch.png");

            String MatchedText;

            using (var engine = new TesseractEngine("tesseract-ocr", "eng", EngineMode.Default))
            {
                using (var pix = PixConverter.ToPix(bmp))
                {
                    using (var page = engine.Process(pix))
                    {
                        //3. Get matched text from tesseract
                        MatchedText = page.GetText();
                    }
                }
            }

            String[] Lines = MatchedText.Split(new char[] { '\n' });
            String Word = Lines[0];

            return Word;
        }