Skip to content

Commit

Permalink
Fix tesseract-ocr#64. Make box training work
Browse files Browse the repository at this point in the history
This commit is better than 06fc053. Hopefully, this is the last fix to box training issue.
  • Loading branch information
amitdo committed Jan 29, 2016
1 parent 3fecb9d commit 4935fdd
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 4935fdd

Please sign in to comment.