From 28e0b0fa95c12923138768d670b852242a750d0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Engelthaler?= Date: Thu, 14 Jun 2018 09:18:47 +0200 Subject: [PATCH] Fix #641,#692 - Added support for tesseract version >=4.0.0 --- src/openalpr/ocr/tesseract_ocr.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/openalpr/ocr/tesseract_ocr.cpp b/src/openalpr/ocr/tesseract_ocr.cpp index 2217ff5..5d56d55 100644 --- a/src/openalpr/ocr/tesseract_ocr.cpp +++ b/src/openalpr/ocr/tesseract_ocr.cpp @@ -42,8 +42,12 @@ namespace alpr std::cerr << "Expecting at least " << MINIMUM_TESSERACT_VERSION << ", your version is: " << tesseract.Version() << endl; } + string TessdataPrefix = config->getTessdataPrefix(); + if (cmpVersion(tesseract.Version(), "4.0.0") >= 0) + TessdataPrefix += "tessdata/"; + // Tesseract requires the prefix directory to be set as an env variable - tesseract.Init(config->getTessdataPrefix().c_str(), config->ocrLanguage.c_str() ); + tesseract.Init(TessdataPrefix.c_str(), config->ocrLanguage.c_str() ); tesseract.SetVariable("save_blob_choices", "T"); tesseract.SetVariable("debug_file", "/dev/null"); tesseract.SetPageSegMode(PSM_SINGLE_CHAR);