# Teoría El reconocimiento óptico de caracteres (OCR) es una tecnología utilizada para convertir diferentes tipos de documentos, como imágenes, documentos impresos escaneados, fotografías de tecto, archivos pdf, o imágenes capturadas con una cámara, en datos editables y buscables.

Instalar paquetes y llamar librerías

#install.packages("tesseract") # OCR
library(tesseract)
#install.packages("magick") # PNG
library(magick)
## Warning: package 'magick' was built under R version 4.3.3
## Linking to ImageMagick 6.9.12.93
## Enabled features: cairo, fontconfig, freetype, heic, lcms, pango, raw, rsvg, webp
## Disabled features: fftw, ghostscript, x11
#install.packages("officer") # Word
library(officer)
## Warning: package 'officer' was built under R version 4.3.2
#install.packages("pdftools") # pdf
library(pdftools)
## Using poppler version 23.04.0

Obtener texto de una imagen PNG

# file.choose()
imagen1 <- image_read("/Users/yessicaacosta/Desktop/Captura de Pantalla 2024-08-12 a la(s) 15.33.13.png")
texto1 <- ocr(imagen1)
texto1
## [1] "¢ In supervised learning the agent observes input-output pairs and learns a function that Supervised learning\nmaps from input to output. For example, the inputs could be camera images, each\none accompanied by an output saying “bus” or “pedestrian,” etc. An output like this\nis called a label. The agent learns a function that, when given a new image, predicts Label\nthe appropriate label. In the case of braking actions (component 1 above), an input is\nthe current state (speed and direction of the car, road condition), and an output is the\ndistance it took to stop. In this case a set of output values can be obtained by the agent\nfrom its own percepts (after the fact); the environment is the teacher, and the agent\nlearns a function that maps states to stopping distance.\n¢ In unsupervised learning the agent learns patterns in the input without any explicit leone sed\nfeedback. The most common unsupervised learning task is clustering: detecting poten-\ntially useful clusters of input examples. For example, when shown millions of images\ntaken from the Internet, a computer vision system can identify a large cluster of similar\nimages which an English speaker would call “cats.”\n¢ In reinforcement learning the agent learns from a series of reinforcements: rewards Reinforcement\nand punishments. For example, at the end of a chess game the agent is told that it has\nwon (a reward) or lost (a punishment). It is up to the agent to decide which of the\nactions prior to the reinforcement were most responsible for it, and to alter its actions\nto aim towards more rewards in the future.\n"
LS0tCnRpdGxlOiAiT0NSIgphdXRob3I6IFllc3NpY2EgQWNvc3R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