Exemplo n.º 1
0
 private void DoOCR(string tag)
 {
     if (tag != string.Empty)
     {
         try
         {
             var path = Path.Combine(Application.StartupPath, @"tessdata");
             Console.WriteLine(path);
             using (var engine = new TesseractEngine(path, tag.ToLower(), EngineMode.TesseractAndCube))
             {
                 using (var img = new Bitmap(pictureBox1.Image))
                 {
                     using (var page = engine.Process(img))
                     {
                         var text = page.GetText();
                         if (text != String.Empty)
                         {
                             using (var frm = new OCRMask(text))
                             {
                                 frm.ShowDialog();
                             }
                         }
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex);
         }
     }
 }
Exemplo n.º 2
0
 private void DoOCR(string tag)
 {
     if (tag != string.Empty)
     {
         try
         {
             var path = Path.Combine(Application.StartupPath, @"tessdata");
             Console.WriteLine(path);
             using (var engine = new TesseractEngine(path, tag.ToLower(), EngineMode.TesseractAndCube))
             {
                 using (var img = new Bitmap(pictureBox1.Image))
                 {
                     using (var page = engine.Process(img))
                     {
                         var text = page.GetText();
                         if (text != String.Empty)
                         {
                             using (var frm = new OCRMask(text))
                             {
                                 frm.ShowDialog();
                             }
                         }
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex);
         }
     }
 }