# OCR - Optical Character Recognition This software implements a heavily parallelized pipeline to recognize text in PDF files. It is used for nopaque's OCR service but you can also use it standalone, for that purpose a convenient wrapper script is provided. ## Software used in this pipeline implementation - Official Debian Docker image (buster-slim) and programs from its free repositories: https://hub.docker.com/_/debian - ocropy (1.3.3): https://github.com/ocropus/ocropy/releases/tag/v1.3.3 - pyFlow (1.1.20): https://github.com/Illumina/pyflow/releases/tag/v1.1.20 - Tesseract OCR (4.1.1): https://github.com/tesseract-ocr/tesseract/releases/tag/4.1.1 - tessdata_best (4.1.0): https://github.com/tesseract-ocr/tessdata_best/releases/tag/4.1.0 ## Use this image 1. Create input and output directories for the pipeline. ``` bash mkdir -p //input //output ``` 2. Place your PDF files inside `//input`. Files should all contain text of the same language. 3. Start the pipeline process. Check the [Pipeline arguments](#pipeline-arguments) section for more details. ``` # Option one: Use the wrapper script ## Install the wrapper script (only on first run). Get it from https://gitlab.ub.uni-bielefeld.de/sfb1288inf/ocr/-/raw/1.0.0/wrapper/ocr, make it executeable and add it to your ${PATH} cd / ocr -i input -l -o output # Option two: Classic Docker style docker run \ --rm \ -it \ -u $(id -u $USER):$(id -g $USER) \ -v //input:/input \ -v //output:/output \ gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/ocr:1.0.0 \ -i /input \ -l -o /output \ ``` 4. Check your results in the `//output` directory. ``` ### Pipeline arguments `-l languagecode` * Tells tesseract which language will be used. * options = deu (German), eng (English), enm (Middle englisch), fra (French), frk (German Fraktur), frm (Middle french), ita (Italian), por (Portuguese), spa (Spanish) * required = True `--keep-intermediates` * If set, all intermediate files created during the OCR process will be kept. * default = False * required = False `--nCores corenumber` * Sets the number of CPU cores being used during the OCR process. * default = min(4, multiprocessing.cpu_count()) * required = False `--skip-binarisation` * Used to skip binarization with ocropus. If skipped, only the tesseract binarization is used. * default = False ``` bash # Example with all arguments used docker run \ --rm \ -it \ -u $(id -u $USER):$(id -g $USER) \ -v "$HOME"/ocr/input:/input \ -v "$HOME"/ocr/output:/output \ gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/ocr:1.0.0 \ -i /input \ -l eng \ -o /output \ --keep_intermediates \ --nCores 8 \ --skip-binarisation ```