Skip to content

Commit

Permalink
Produce warning for invalid resolution. Fix #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 94aebb1 commit ed4c4c6
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
Expand Up @@ -2223,6 +2223,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
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 ed4c4c6

Please sign in to comment.