Extract text from an image. Requires that you have training data for the language you
are reading. Works best for images with high contrast, little noise and horizontal text.
See tesseract wiki and
the package vignette for image preprocessing tips.
character vector of text extracted from the file. If the file
is has TIFF or PDF extension, it will be a vector of length equal to the
number of pages.
Arguments
file
file path or raw vector (png, tiff, jpeg, etc).
engine
a tesseract engine created with tesseract(). Alternatively a
language string which will be passed to tesseract().
HOCR
if TRUE return results as HOCR xml instead of plain text
opw
owner password to open pdf (please pass it as an environment
variable to avoid leaking sensitive information)
upw
user password to open pdf (please pass it as an environment
variable to avoid leaking sensitive information)
Details
The ocr() function returns plain text by default, or hOCR text if hOCR is set to TRUE.
The ocr_data() function returns a data frame with a confidence rate and bounding box for
each word in the text.