Title: | Open Source OCR Engine |
---|---|
Description: | Bindings to 'Tesseract': a powerful optical character recognition (OCR) engine that supports over 100 languages. The engine is highly configurable in order to tune the detection algorithms and obtain the best possible results. |
Authors: | Jeroen Ooms [aut] , Mauricio Vargas Sepulveda [aut, cre] , Munk School of Global Affairs and Public Policy [fnd] |
Maintainer: | Mauricio Vargas Sepulveda <[email protected]> |
License: | Apache License (>= 2) |
Version: | 5.3.2 |
Built: | 2024-11-07 13:40:02 UTC |
Source: | CRAN |
Bindings to 'Tesseract': a powerful optical character recognition (OCR) engine that supports over 100 languages. The engine is highly configurable in order to tune the detection algorithms and obtain the best possible results.
Maintainer: Mauricio Vargas Sepulveda [email protected] (ORCID)
Authors:
Jeroen Ooms [email protected] (ORCID)
Other contributors:
Munk School of Global Affairs and Public Policy [funder]
Useful links:
Report bugs at https://github.com/pachadotdev/cpp11tesseract/issues
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 our package vignette for image preprocessing tips.
ocr(image, engine = tesseract("eng"), HOCR = FALSE) ocr_data(image, engine = tesseract("eng"))
ocr(image, engine = tesseract("eng"), HOCR = FALSE) ocr_data(image, engine = tesseract("eng"))
image |
file path, url, or raw vector to image (png, tiff, jpeg, etc) |
engine |
a tesseract engine created with |
HOCR |
if |
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.
character vector of text extracted from the image
Other tesseract:
tesseract()
,
tesseract_download()
# Simple example file <- system.file("examples", "testocr.png", package = "cpp11tesseract") text <- ocr(file) cat(text)
# Simple example file <- system.file("examples", "testocr.png", package = "cpp11tesseract") text <- ocr(file) cat(text)
Create an OCR engine for a given language and control parameters. This can be used by the ocr and ocr_data functions to recognize text.
tesseract( language = "eng", datapath = NULL, configs = NULL, options = NULL, cache = TRUE ) tesseract_params(filter = "") tesseract_info()
tesseract( language = "eng", datapath = NULL, configs = NULL, options = NULL, cache = TRUE ) tesseract_params(filter = "") tesseract_info()
language |
string with language for training data. Usually defaults to |
datapath |
path with the training data for this language. Default uses the system library. |
configs |
character vector with files, each containing one or more parameter values. These config files can exist in the current directory or one of the standard tesseract config files that live in the tessdata directory. See details. |
options |
a named list with tesseract parameters. See details. |
cache |
speed things up by caching engines |
filter |
only list parameters containing a particular string |
Tesseract control parameters can be set either via a named list in the
options
parameter, or in a config
file text file which contains the parameter name
followed by a space and then the value, one per line. Use tesseract_params()
to list
or find parameters. Note that that some parameters are only supported in certain versions
of libtesseract, and that invalid parameters can sometimes cause libtesseract to crash.
no return value, called for side effects
no return value, called for side effects
list with information about the tesseract engine
Other tesseract:
ocr()
,
tesseract_download()
tesseract_params("debug")
tesseract_params("debug")
Helper function to download training data from the official tessdata repository. On Linux, the fast training data can be installed directly with yum or apt-get.
Helper function to download training data from the contributed tessdata_contrib repository.
tesseract_download( lang, datapath = NULL, model = c("fast", "best"), progress = interactive() ) tesseract_contributed_download( lang, datapath = NULL, model = c("fast", "best"), progress = interactive() )
tesseract_download( lang, datapath = NULL, model = c("fast", "best"), progress = interactive() ) tesseract_contributed_download( lang, datapath = NULL, model = c("fast", "best"), progress = interactive() )
lang |
three letter code for language, see tessdata repository. |
datapath |
destination directory where to download store the file |
model |
either |
progress |
print progress while downloading |
Tesseract uses training data to perform OCR. Most systems default to English training data. To improve OCR performance for other languages you can to install the training data from your distribution. For example to install the spanish training data:
tesseract-ocr-spa (Debian, Ubuntu)
tesseract-langpack-spa
(Fedora, EPEL)
On Windows and MacOS you can install languages using the tesseract_download function
which downloads training data directly from github
and stores it in a the path on disk given by the TESSDATA_PREFIX
variable.
no return value, called for side effects
no return value, called for side effects
Other tesseract:
ocr()
,
tesseract()
Other tesseract:
ocr()
,
tesseract()
# download the french training data tesseract_download("fra", model = "best", datapath = tempdir()) if (any("fra" %in% tesseract_info()$available)) { french <- tesseract("fra") file <- system.file("examples", "french.png", package = "cpp11tesseract") text <- ocr(file, engine = french) cat(text) } # download the polytonic greek training data tesseract_contributed_download("grc_hist", model = "best", datapath = tempdir()) if (any("grc_hist" %in% tesseract_info()$available)) { greek <- tesseract("grc_hist") file <- system.file("examples", "polytonicgreek.png", package = "cpp11tesseract") text <- ocr(file, engine = greek) cat(text) }
# download the french training data tesseract_download("fra", model = "best", datapath = tempdir()) if (any("fra" %in% tesseract_info()$available)) { french <- tesseract("fra") file <- system.file("examples", "french.png", package = "cpp11tesseract") text <- ocr(file, engine = french) cat(text) } # download the polytonic greek training data tesseract_contributed_download("grc_hist", model = "best", datapath = tempdir()) if (any("grc_hist" %in% tesseract_info()$available)) { greek <- tesseract("grc_hist") file <- system.file("examples", "polytonicgreek.png", package = "cpp11tesseract") text <- ocr(file, engine = greek) cat(text) }