I would like to use tesseract OCR to get text on a rectangular area of the screen using c# on Visual Studio C#.
First, what are required to get tesseract working in Visual Studio C#? I am new to use Visual Studio and setting up wrappers. After hours of searching on Google, I found I would need: a wrapper(charlesw), a language pack from official site. Do I also need to install windows tesseract-ocr?
I have followed the steps on charlesw's GitHu to setup the wrapper in my project. Yet, I am still not sure how to use the functions.
I assume this is how to declare an OCR engine:
TesseractEngine engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default);
To analyze the rectangular region on the screen, I could capture the screen of certain region, and then save it in .bmp or .tif. Next, to use the engine to analyze the image.
engine.[unkwonapi](imagepath); //what is the api name going to be? I tried to look it up [here][2].
Or, some people said it could be done by using tesseract's api, where we can input the coordination of the rectangular region.
The wrapper bundles Tesseract DLL (as libtesseract302.dll
). You do not need to install windows tesseract-ocr; as a matter of fact, you should not, as it can interfere with the wrapper.
You can use either of the following to specify a region of interest on the image:
engine.Process(Bitmap image, Rect region, PageSegMode? pageSegMode = null)
or
engine.Process(Pix image, Rect region, PageSegMode? pageSegMode = null)