SetRectangle: Focus the OCR on a Sub-Region of the Image

SetRectangleR Documentation

Focus the OCR on a Sub-Region of the Image

Description

SetRectangle restricts the OCR to a sub-rectangle of the original image. After calling SetRectangle, the next recognition done by the tesseract instance will only look at that region. This is useful when one knows a priori that only a subset of the image is of interest.

Usage

SetRectangle(api, ..., dims = sapply(list(...), as.integer))

Arguments

api

an instance of the TesseractBaseAPI-class obtained from a call to tesseract

...

the specification of the rectangle as left, top, width and height.

dims

an alternative mechanism for specifying the location of the corners of the rectangle as a single object, a vector of integer values. The elements identify the left, top, width and height of the rectangle This should NOT be the coordinates of the top-left and bottom-right of the rectangle, i.e. (x1, y1, x2, y2). The 3rd and 4th values are the width and height of the box.

Value

NULL. The function is used for its side-effect on the tesseract instance.

Author(s)

Duncan Temple Lang

References

https://zdenop.github.io/tesseract-doc/group___advanced_a_p_i.html#ga284228c7e9d18bbbd3984d44e252d625

See Also

tesseract, Recognize, GetText

Examples

f = system.file("images", "1990_p44.png", package = "Rtesseract")
ts = tesseract(f)
dims = GetImageDims(ts)
 # region chosen interactively
SetRectangle(ts, 500, 800, 1300, 800)
GetText(ts)

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