Skip to content

Commit

Permalink
Merge pull request tesseract-ocr#206 from amitdo/fix-box-training
Browse files Browse the repository at this point in the history
Fix tesseract-ocr#64. Make box training work
  • Loading branch information
zdenop committed Jan 31, 2016
2 parents f5fa2f6 + 008c3e1 commit ec38bd6
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions api/tesseractmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ void ParseArgs(const int argc, char** argv,
void PreloadRenderers(tesseract::TessBaseAPI* api,
tesseract::PointerVector<tesseract::TessResultRenderer>* 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 {
Expand Down Expand Up @@ -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));
}
}
Expand Down Expand Up @@ -422,16 +421,21 @@ int main(int argc, char **argv) {
(api.GetBoolVariable("tessedit_make_boxes_from_boxes", &b) && b);

tesseract::PointerVector<tesseract::TessResultRenderer> 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
}

0 comments on commit ec38bd6

Please sign in to comment.