Water's Home

Just another Life Style

0%

Tesseract OCR API

Tesseract API — OCR

tesseract::TessBaseAPI ocr;

char* identifyText(Mat input, char* language = “eng”)
{
ocr.Init(NULL, language, tesseract::OEM_TESSERACT_ONLY);
ocr.SetVariable(“tessedit_write_images”, “1”);
ocr.SetPageSegMode(tesseract::PSM_SINGLE_BLOCK);
ocr.SetImage(input.data, input.cols, input.rows, input.elemSize(), input.cols);

char* text = ocr.GetUTF8Text();
cout << “Text:” << endl;
cout << text << endl;
cout << “Confidence: “ << ocr.MeanTextConf() << endl << endl;

// Get the text
return text;
}