Skip to content

Commit

Permalink
Produce warning for invalid resolution. Fix tesseract-ocr#453
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreiden authored and zdenop committed Dec 7, 2016
1 parent b09361b commit f6c33c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions api/baseapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2220,6 +2220,8 @@ void TessBaseAPI::Threshold(Pix** pix) {
if (y_res < kMinCredibleResolution || y_res > kMaxCredibleResolution) {
// Use the minimum default resolution, as it is safer to under-estimate
// than over-estimate resolution.
tprintf("Warning. Invalid resolution %d dpi. Using %d instead.\n",
y_res, kMinCredibleResolution);
thresholder_->SetSourceYResolution(kMinCredibleResolution);
}
PageSegMode pageseg_mode =
Expand Down
10 changes: 8 additions & 2 deletions ccmain/osdetect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,14 @@ void remove_nontext_regions(tesseract::Tesseract *tess, BLOCK_LIST *blocks,
int vertical_y = 1;
tesseract::TabVector_LIST v_lines;
tesseract::TabVector_LIST h_lines;
int resolution = (kMinCredibleResolution > pixGetXRes(pix)) ?
kMinCredibleResolution : pixGetXRes(pix);
int resolution;
if (kMinCredibleResolution > pixGetXRes(pix)) {
resolution = kMinCredibleResolution;
tprintf("Warning. Invalid resolution %d dpi. Using %d instead.\n",
pixGetXRes(pix), resolution);
} else {
resolution = pixGetXRes(pix);
}

tesseract::LineFinder::FindAndRemoveLines(resolution, false, pix,
&vertical_x, &vertical_y,
Expand Down

0 comments on commit f6c33c0

Please sign in to comment.