Fix usage of tesserr stream

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2024-12-19 13:29:13 +01:00
parent 1ea0ef29a4
commit bb9604fbf0
2 changed files with 7 additions and 8 deletions

View File

@ -29,6 +29,7 @@
#include "params.h"
#include "stopper.h"
#include "tesseractclass.h"
#include "tesserrstream.h" // for tesserr
#include "tessvars.h"
#include "tprintf.h"
#ifndef DISABLED_LEGACY_ENGINE
@ -86,10 +87,9 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0,
// Initialize TessdataManager.
if (!mgr->is_loaded() && !mgr->Init(tessdata_path.string().c_str())) {
tprintf("Error opening data file %s\n", tessdata_path.string());
tprintf(
tesserr << "Error opening data file " << tessdata_path.string() << '\n' <<
"Please make sure the TESSDATA_PREFIX environment variable is set"
" to your \"tessdata\" directory.\n");
" to your \"tessdata\" directory.\n";
return false;
}
#ifdef DISABLED_LEGACY_ENGINE
@ -182,9 +182,8 @@ bool Tesseract::init_tesseract_lang_data(const std::string &arg0,
}
#ifndef DISABLED_LEGACY_ENGINE
else if (!mgr->GetComponent(TESSDATA_UNICHARSET, &fp) || !unicharset.load_from_file(&fp, false)) {
tprintf(
"Error: Tesseract (legacy) engine requested, but components are "
"not present in %s!!\n", tessdata_path.string());
tesserr << "Error: Tesseract (legacy) engine requested, but components are "
"not present in " << tessdata_path.string() << "!!\n";
return false;
}
#endif // ndef DISABLED_LEGACY_ENGINE

View File

@ -11,6 +11,7 @@
// limitations under the License.
#include "ccutil.h"
#include "tesserrstream.h" // for tesserr
#include "tprintf.h" // for tprintf
#include <cstdlib>
@ -51,8 +52,7 @@ std::filesystem::path find_data_path(const std::string &argv0) {
if (!argv0.empty()) {
std::filesystem::path path(argv0);
if (!std::filesystem::is_directory(path)) {
tprintf("Warning (tessdata): '%s' is not a valid directory.\n",
argv0);
tesserr << "Warning (tessdata): '" << argv0 << "' is not a valid directory.\n";
}
return path;
}