Skip to content

Commit

Permalink
Fix loading of additional model files (issue tesseract-ocr#3635)
Browse files Browse the repository at this point in the history
Modernize also a for loop statement.

Fixes: d6de055 ("Set default language for tesseract only if required")
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Nov 10, 2021
1 parent 8279006 commit 9091055
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/ccmain/tessedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ int Tesseract::init_tesseract(const std::string &arg0, const std::string &textba
std::vector<std::string> langs_not_to_load;
ParseLanguageString(language, &langs_to_load, &langs_not_to_load);

// Set the basename, compute the data directory.
main_setup(arg0, textbase);

for (auto *lang : sub_langs_) {
delete lang;
}
Expand All @@ -310,8 +307,7 @@ int Tesseract::init_tesseract(const std::string &arg0, const std::string &textba
// Load the rest into sub_langs_.
// A range based for loop does not work here because langs_to_load
// might be changed in the loop when a new submodel is found.
for (size_t lang_index = 0; lang_index < langs_to_load.size(); ++lang_index) {
auto &lang_to_load = langs_to_load[lang_index];
for (auto &lang_to_load : langs_to_load) {
if (!IsStrInList(lang_to_load, langs_not_to_load)) {
const char *lang_str = lang_to_load.c_str();
Tesseract *tess_to_init;
Expand Down Expand Up @@ -399,6 +395,9 @@ int Tesseract::init_tesseract_internal(const std::string &arg0, const std::strin
const std::vector<std::string> *vars_vec,
const std::vector<std::string> *vars_values,
bool set_only_non_debug_params, TessdataManager *mgr) {
// Set the basename, compute the data directory.
main_setup(arg0, textbase);

if (!init_tesseract_lang_data(arg0, language, oem, configs, configs_size, vars_vec,
vars_values, set_only_non_debug_params, mgr)) {
return -1;
Expand Down

0 comments on commit 9091055

Please sign in to comment.