Tweak MIN_OCR_SIZE behavior, update gitignore

This commit is contained in:
simon987 2022-01-08 10:33:02 -05:00
parent fe1aa6dd4c
commit 255bc2d689
3 changed files with 5 additions and 3 deletions

2
.gitignore vendored
View File

@ -24,3 +24,5 @@ Testing/
test_i test_i
test_i_inc test_i_inc
node_modules/ node_modules/
.cmake/
i_inc/

View File

@ -233,7 +233,7 @@ void fill_image(fz_context *fzctx, UNUSED(fz_device *dev),
int l2factor = 0; int l2factor = 0;
if (img->w > MIN_OCR_SIZE && img->h > MIN_OCR_SIZE && OCR_IS_VALID_BPP(img->n)) { if (img->w >= MIN_OCR_SIZE && img->h >= MIN_OCR_SIZE && OCR_IS_VALID_BPP(img->n)) {
fz_pixmap *pix = img->get_pixmap(fzctx, img, NULL, img->w, img->h, &l2factor); fz_pixmap *pix = img->get_pixmap(fzctx, img, NULL, img->w, img->h, &l2factor);
ocr_extract_text(thread_ctx.tesseract_path, thread_ctx.tesseract_lang, pix->samples, pix->w, pix->h, pix->n, pix->stride, pix->xres, fill_image_ocr_cb); ocr_extract_text(thread_ctx.tesseract_path, thread_ctx.tesseract_lang, pix->samples, pix->w, pix->h, pix->n, pix->stride, pix->xres, fill_image_ocr_cb);
fz_drop_pixmap(fzctx, pix); fz_drop_pixmap(fzctx, pix);

View File

@ -19,7 +19,7 @@ ocr_extract_text(const char *tesseract_path, const char *tesseract_lang,
const int img_bpp, const int img_stride, const int img_xres, const int img_bpp, const int img_stride, const int img_xres,
const ocr_extract_callback_t cb) { const ocr_extract_callback_t cb) {
if (img_w <= MIN_OCR_SIZE || img_h <= MIN_OCR_SIZE || img_xres <= 0 || if (img_w < MIN_OCR_SIZE || img_h < MIN_OCR_SIZE || img_xres <= 0 ||
!OCR_IS_VALID_BPP(img_bpp)) { !OCR_IS_VALID_BPP(img_bpp)) {
return; return;
} }