ambrish dhaka

ambrish dhaka

  • NA
  • 4
  • 1.5k

Tesseract usage in C#

Jul 27 2019 5:08 AM
I am a beginner in C#. I am trying to use tesseract.exe located as an independent application in Program files, which I have installed as a separate program. I want to use this .exe file to read clipboard image and then store the output in a windows form. All this needs to be done with a button click. My code is as follows:
  1. private void B8_Click(object sender, EventArgs e)  
  2. {  
  3. string ts = "C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe";  
  4. m = Clipboard.GetImage();  
  5. string lang = "eng";  
  6. if (m != null)  
  7. {  
  8. Process w = new Process();  
  9. w.StartInfo.UseShellExecute = false;  
  10. w.StartInfo.FileName = ts;  
  11. w.StartInfo.Arguments = string.Format("\"{0}\" \"{1}\" -l {2}", m, v, lang);  
  12. w.Start();  
  13. w.Close();  
  14. tb5.AppendText(v + Environment.NewLine);  
  15. Clipboard.Clear();  
  16. m = null;  
  17. v = null;  
  18. }  
  19. else  
  20. {  
  21. MessageBox.Show("No Image.");  
  22. }  
This gives nothing in textbox. Thanks in advance.

Answers (5)