From 11a57c7a176f49cb889ffd8847f938f892fc29f3 Mon Sep 17 00:00:00 2001 From: "James R. Barlow" Date: Sun, 23 Jun 2019 16:54:43 -0700 Subject: [PATCH] Drop --mask-barcodes feature --- docs/cookbook.rst | 4 ---- src/ocrmypdf/_pipeline.py | 11 ++--------- src/ocrmypdf/api.py | 1 - src/ocrmypdf/cli.py | 7 ------- 4 files changed, 2 insertions(+), 21 deletions(-) diff --git a/docs/cookbook.rst b/docs/cookbook.rst index bc6ca951..617a6046 100644 --- a/docs/cookbook.rst +++ b/docs/cookbook.rst @@ -174,10 +174,6 @@ might remove desirable content, especially from poor quality scans. - ``--clean-final`` uses unpaper to clean up pages before OCR and inserts the page into the final output. You will want to review each page to ensure that unpaper did not remove something important. -- ``--mask-barcodes`` will suppress any barcodes detected in a page - image. Barcodes are known to confuse Tesseract OCR and interfere with - the recognition of text on the same baseline as a barcode. The output - file will contain the unaltered image of the barcode. .. note:: diff --git a/src/ocrmypdf/_pipeline.py b/src/ocrmypdf/_pipeline.py index db7e7464..e365fd0f 100644 --- a/src/ocrmypdf/_pipeline.py +++ b/src/ocrmypdf/_pipeline.py @@ -531,16 +531,9 @@ def create_ocr_image(image, page_context): draw.rectangle(pixcoords, fill=white) # draw.rectangle(pixcoords, outline=pink) - if options.mask_barcodes or options.threshold: + if options.threshold: pix = leptonica.Pix.frompil(im) - if options.threshold: - pix = pix.masked_threshold_on_background_norm() - if options.mask_barcodes: - barcodes = pix.locate_barcodes() - for barcode in barcodes: - decoded, rect = barcode - page_context.log.debug('masking barcode %s %r', decoded, rect) - draw.rectangle(rect, fill=white) + pix = pix.masked_threshold_on_background_norm() im = pix.topil() if options.filter_ocr_image: diff --git a/src/ocrmypdf/api.py b/src/ocrmypdf/api.py index 94c3c6d3..f68ba611 100644 --- a/src/ocrmypdf/api.py +++ b/src/ocrmypdf/api.py @@ -180,7 +180,6 @@ def run( # pylint: disable=unused-argument unpaper_args=None, oversample=None, remove_vectors=None, - mask_barcodes=None, threshold=None, force_ocr=None, skip_text=None, diff --git a/src/ocrmypdf/cli.py b/src/ocrmypdf/cli.py index 6fe45275..d3011995 100644 --- a/src/ocrmypdf/cli.py +++ b/src/ocrmypdf/cli.py @@ -267,13 +267,6 @@ preprocessing.add_argument( help="EXPERIMENTAL. Mask out any vector objects in the PDF so that they " "will not be included in OCR. This can eliminate false characters.", ) -preprocessing.add_argument( - '--mask-barcodes', - action='store_true', - help="EXPERIMENTAL. Mask out any barcodes that appear in the PDF so they are not " - "considered during OCR. Barcodes can introduce false characters into " - "OCR.", -) preprocessing.add_argument( '--threshold', action='store_true',