View Source Tesserax.Command (Tesserax v0.1.2)

Builds a command containing information about Tesseract and which image to read.

Examples

command = Tesserax.Command.make_command(
            image: File.read("path/to/image"), 
            languages: ["eng", "hin"], 
            tessdata: "path/to/tessdata/dir",
            config: "path/to/config/file",
            psm: psm_value,
            oem: oem_value
          )

Tesserax.Command.image(command)
#=> <<...>>

Tesserax.Command.languages(command)
#=> "eng+hin"

Tesserax.Command.tessdata(command)
#=> "path/to/tessdata/dir"

Tesserax.Command.config(command)
#=> "path/to/config/file"

Tesserax.Command.psm(command)
#=> psm_value

Tesserax.Command.oem(command)
#=> oem_value

Summary

Functions

Fetches the config file path from the command.

Fetches image field from the command.

Fetches the languages from the command.

Builds a command with available options: :image, :languages, :tessdata, :config, :psm, :oem.

Fetches the oem value from the command.

Prepares a command. Returns a map with non-nil values from the command.

Fetches the psm value from the command.

Fetches the tessdata path from the command.

Fetches all values from a command.

Types

@type t() :: %Tesserax.Command{
  config: String.t(),
  image: binary(),
  languages: String.t(),
  oem: integer(),
  psm: integer(),
  tessdata: String.t()
}

Functions

@spec config(t()) :: String.t()

Fetches the config file path from the command.

@spec image(t()) :: binary()

Fetches image field from the command.

@spec languages(t()) :: String.t()

Fetches the languages from the command.

Link to this function

make_command(command \\ %__MODULE__{}, opts)

View Source
@spec make_command(
  t(),
  keyword()
) :: t()

Builds a command with available options: :image, :languages, :tessdata, :config, :psm, :oem.

  • :image is either the contents of an image (PNG format), or the path to an image.
  • :languages is the languages that Tesseract should recognize with, either a list or a string.
  • :tessdata is the path to tessdata dir.
  • :config is the path to the config file.
  • :psm is an integer representing Page Segmentation Mode in Tesseract.
  • :oem is an integer representing Ocr Engine Mode in Tesseract. Ignores invalid options.

Examples

Tesserax.Command.make_command(
  image: File.read!("path/to/image"), 
  languages: ["eng", "hin"], 
  tessdata: "path/to/tessdata/dir", 
  config: "path/to/config/file", 
  psm: 0, 
  oem: 0
)
@spec oem(t()) :: integer()

Fetches the oem value from the command.

Link to this function

prepare_command(command)

View Source
@spec prepare_command(t()) :: map()

Prepares a command. Returns a map with non-nil values from the command.

@spec psm(t()) :: integer()

Fetches the psm value from the command.

@spec tessdata(t()) :: String.t()

Fetches the tessdata path from the command.

@spec values(t()) :: list()

Fetches all values from a command.