Tesseract OCR API

Tesseract API — OCR

  1. tesseract::TessBaseAPI ocr;
  2.  
  3. char* identifyText(Mat input, char* language = "eng") 
  4. {	
  5. 	ocr.Init(NULL, language, tesseract::OEM_TESSERACT_ONLY);	
  6. 	ocr.SetVariable("tessedit_write_images", "1");
  7. 	ocr.SetPageSegMode(tesseract::PSM_SINGLE_BLOCK);
  8. 	ocr.SetImage(input.data, input.cols, input.rows, input.elemSize(), input.cols);
  9.  
  10. 	char* text = ocr.GetUTF8Text();
  11. 	cout << "Text:" << endl;
  12. 	cout << text << endl;
  13. 	cout << "Confidence: " << ocr.MeanTextConf() << endl << endl;
  14.  
  15. 	// Get the text    
  16. 	return text;
  17. }

Leave a Reply

Your email address will not be published. Required fields are marked *