Code Monkey home page Code Monkey logo

ocrd_im6convert's Introduction

ocrd_imageconvert

Thin wrapper around convert(1)

Introduction

ImageMagick's convert CLI contains a treasure trove of image operations. This wrapper aims to provide much of that as an OCR-D compliant processor.

Installation

This module requires GNU make (for installation) and the ImageMagick command line tools (at runtime). On Ubuntu 18.04 (or similar), you can install them by running:

sudo apt-get install make
sudo make deps-ubuntu # or: apt-get install imagemagick

Moreover, an installation of OCR-D core is needed:

make deps # or: pip install ocrd

This will install the Python package ocrd in your current environment. (Setting up a venv is strongly recommended.)

Lastly, the provided shell script ocrd-im6convert works best when copied into your PATH, referencing its ocrd-tool.json under a known path. This can be done by running:

make install

This will copy the binary and JSON file under $PREFIX, which variable you can override to your needs. The default value is to use PREFIX=$VIRTUAL_ENV if you have already activated a venv, or PREFIX=$PWD/.local (i.e. under the current working directory).

Usage

This package provides ocrd-im6convert as a OCR-D processor (command line interface). It uses the following parameters:

    "ocrd-im6convert": {
      "executable": "ocrd-im6convert",
      "categories": ["Image preprocessing"],
      "steps": ["preprocessing/optimization"],
      "description": "Convert and transform images",
      "input_file_grp": [
        "OCR-D-IMG"
      ],
      "output_file_grp": [
        "OCR-D-IMG"
      ],
      "parameters": {
        "input-options": {
          "type": "string",
          "description": "e.g. -density 600x600 -wavelet-denoise 1%x0.1",
          "default": ""
        },
        "output-format": {
          "type": "string",
          "description": "Desired media type of output",
          "required": true,
          "enum": ["image/tiff", "image/jp2", "image/png"]
        },
        "output-options": {
          "type": "string",
          "description": "e.g. -resample 300x300 -alpha deactivate -normalize -despeckle -noise 2 -negate -morphology close diamond",
          "default": ""
        }
      }
    }

Cf. IM documentation or man-page convert(1) for formats and options.

Example

ocrd-im6convert -I OCR-D-IMG -O OCR-D-IMG-SMALL -p '{ "output-format": "image/png", "output-options": "-resize 24%" }'

(This downscales the images in the input file group OCR-D-IMG to 24% and stores them as PNG files under the output file group OCR-D-IMG-SMALL.)

Testing

None yet

ocrd_im6convert's People

Contributors

bertsky avatar kba avatar stweil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ocrd_im6convert's Issues

documentation: README completness, debug ocrd-tool.json

Please debug your ocrd_tool.json file.
I found some errors:

<report valid="false">
  <error>[tools.ocrd-im6convert] 'input_file_grp' is a required property</error>
  <error>[tools.ocrd-im6convert] 'output_file_grp' is a required property</error>
  <error>[tools.ocrd-im6convert.parameters.output-format] 'description' is a required property</error>
</report>

You can find the ocrd-tool.json documentation: https://ocr-d.github.io/ocrd_tool

Please check your README file and complet them. An ideal README file look like:

# Name of application


## Introduction
...

## Installation
...

## Usage
...

## Testing
...

Thank you very much.

License?

... is missing. Please check other OCR-D repositories as well and add the missing licenses.

script always yields argv error

./ocrd-im6convert -m ../mets.xml -p params.json 
ERROR: Must set $argv (declare -A argv)

This hapens with both Python 2.7.6 and 3.4.3. ocrd version is 0.4.2, bash 4.3.
It looks like this comes from here, but the actual problem seems to be earlier.

If I do this on bash 4.3, it indeed does not work (even with a single variable and no options at all):

declare params
declare -p params

which then gives

bash: declare: params: not found

To be precise, the desired behaviour was only introduced by bash 4.4, which states:

f. The `-p' option to declare and similar builtins will display attributes for
named variables even when those variables have not been assigned values
(which are technically unset).

support PAGE processing

Page-level images might already be referenced in a PAGE-XML file (via Page/@imageFilename), which includes extra annotation already. But ocrd-im6convert currently can only handle images.

As in ocrd-olena-binarize, it should be possible to also process images inside PAGE-XML on the page level. Either by referencing the output image via some AlternativeImage, or by replacing @imageFilename itself (contradicting the OCR-D functional model).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.