Initialising TessBaseAPI - tvn-cosine/tesseract.net GitHub Wiki

How to create an instance of the TessBaseAPI

  1. Example 1

string dataPath= "./tessdata/";
string language = "eng";
OcrEngineMode oem = OcrEngineMode.DEFAULT;
PageSegmentationMode psm = PageSegmentationMode.AUTO_OSD;

TessBaseAPI tessBaseAPI = new TessBaseAPI();

// Initialize tesseract-ocr 
if (!tessBaseAPI.Init(dataPath, language, oem))
{
    throw new Exception("Could not initialize tesseract.");
}

// Set the Page Segmentation mode
tessBaseAPI.SetPageSegMode(psm);
  1. Example 2

string dataPath = "./tessdata/";
string language = "eng";
OcrEngineMode oem = OcrEngineMode.DEFAULT;
PageSegmentationMode psm = PageSegmentationMode.AUTO_OSD;

TessBaseAPI tessBaseAPI = new TessBaseAPI(dataPath, language, oem, psm);