Skip to content

Commit

Permalink
Don't create an empty lstmf file
Browse files Browse the repository at this point in the history
If Tesseract cannot find text in the input image, it should not write
an empty lstmf file. This problem was reported in issue tesseract-ocr#2741.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Nov 1, 2019
1 parent 6f31c3b commit 94d0f77
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ccmain/linerec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ void Tesseract::TrainLineRecognizer(const STRING& input_imagename,
return;
}
TrainFromBoxes(boxes, texts, block_list, &images);
if (images.NumPages() <= 0) {
tprintf("Failed to read pages from %s\n", input_imagename.c_str());
return;
}
images.Shuffle();
if (!images.SaveDocument(lstmf_name.c_str(), nullptr)) {
tprintf("Failed to write training data to %s!\n", lstmf_name.c_str());
Expand Down

0 comments on commit 94d0f77

Please sign in to comment.