Ejemplo n.º 1
0
        private static async Task <string> CrackCaptcha(HttpClient client)
        {
            //System.Diagnostics.Debugger.Break();
            try
            {
                Bitmap captchaBitmap = await LoadPicture(client, "https://signup.leagueoflegends.com/de/signup/captcha/");

                PrepareCaptcha(captchaBitmap);
                captchaBitmap.Save("captcha.png");

                string result = "";

                using (tessnet2.Tesseract ocr = new tessnet2.Tesseract())
                {
                    ocr.Init(Directory.GetCurrentDirectory() + @"\tessdata\", "eng", false);
                    ocr.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");

                    List <tessnet2.Word> wlist = ocr.DoOCR(captchaBitmap, Rectangle.Empty);
                    foreach (tessnet2.Word w in wlist)
                    {
                        result += w.Text;
                    }

                    ocr.Clear();
                    ocr.Dispose();
                    wlist.Clear();

                    return(result);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return("ERROR");
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     _ocrEngine.Dispose();
     _tEngine.Dispose();
     _mEvent.Dispose();
 }