PrintVariables: Query or Set Tesseract Variables

View source: R/ext.R

PrintVariablesR Documentation

Query or Set Tesseract Variables

Description

These functions allow us to query all or some of the tesseract variables controlling the OCR behavior. We can also set these variables from within R.

Usage

GetVariables(api, var)
PrintVariables(api = tesseract(), asDataFrame = FALSE, file = tempfile())
SetVariables(api, ..., opts = list(...))

Arguments

api

an instance of the TesseractBaseAPI-class, created via a call to tesseract

var

a character vector specifying the names of the variables to be queried. If this is omitted, GetVariables returns all of the tesseract variables.

file

the name of a file to which the variable name and values are written. If this is omitted, PrintVariables returns the list of variable values, just like GetVariables.

...

name = value pairs specifying the name of the variable and its new value to be set in the tesseract object.

opts

an alternative way to specify the name = value pairs of variable name and values to set. This allows the caller to compute the variable names and values and pass the resulting list or vector as a single argument rather than as individual arguments in the call.

asDataFrame

a logical value. If TRUE, the options, their values and information describing the purpose of the option are returned as 3-column data frame. If this is FALSE, a named character vector is returned giving the option value and the associated name. No description of the options is returned.

Value

GetVariables returns a named list containing the values for the different tesseract variables. The names are the variable names. This is a list rather than a vector since the tesseract variables can be strings, logical/boolean values, or numbers - either integer or real valued.

PrintVariables called without a value for file returns a named character vector. The type of each variable is lost.

Author(s)

Duncan Temple Lang

References

Tesseract https://code.google.com/p/tesseract-ocr/

See Also

tesseract, TesseractBaseAPI-class

Examples

  api = tesseract()
  v = GetVariables(api)
  head(names(v))
  table(sapply(v, class)) 

  out = tempfile()
  PrintVariables(api, file = out)

duncantl/Rtesseract documentation built on March 25, 2022, 5:50 a.m.