From 4935fdd3672053d2b67447d2330b8d58fed22325 Mon Sep 17 00:00:00 2001 From: amitdo Date: Fri, 29 Jan 2016 03:37:34 +0200 Subject: [PATCH] Fix #64. Make box training work This commit is better than 06fc0533c. Hopefully, this is the last fix to box training issue. --- api/tesseractmain.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/api/tesseractmain.cpp b/api/tesseractmain.cpp index 16f03c6eca..db73d72174 100644 --- a/api/tesseractmain.cpp +++ b/api/tesseractmain.cpp @@ -286,8 +286,7 @@ void ParseArgs(const int argc, char** argv, void PreloadRenderers(tesseract::TessBaseAPI* api, tesseract::PointerVector* renderers, tesseract::PageSegMode pagesegmode, - const char* outputbase, - bool in_training_mode) { + const char* outputbase) { if (pagesegmode == tesseract::PSM_OSD_ONLY) { renderers->push_back(new tesseract::TessOsdRenderer(outputbase)); } else { @@ -317,7 +316,7 @@ void PreloadRenderers(tesseract::TessBaseAPI* api, } api->GetBoolVariable("tessedit_create_txt", &b); - if (b || (renderers->empty() && !in_training_mode)) { + if (b || renderers->empty()) { renderers->push_back(new tesseract::TessTextRenderer(outputbase)); } } @@ -422,16 +421,21 @@ int main(int argc, char **argv) { (api.GetBoolVariable("tessedit_make_boxes_from_boxes", &b) && b); tesseract::PointerVector renderers; - PreloadRenderers(&api, &renderers, pagesegmode, outputbase, - in_training_mode); - if (!renderers.empty() || in_training_mode) { + if (in_training_mode) { + renderers.push_back(NULL); + } else { + PreloadRenderers(&api, &renderers, pagesegmode, outputbase); + } + + if (!renderers.empty()) { bool succeed = api.ProcessPages(image, NULL, 0, renderers[0]); if (!succeed) { fprintf(stderr, "Error during processing.\n"); exit(1); } } + PERF_COUNT_END return 0; // Normal exit }