Tratamento de texto com OCR

Material para o Encontro Virtual 4, 24/11/2021, referente à semana 7 do curso

O objetivo desse encontro virtual é debater o processo de Reconhecimento Ótico de Caracteres - em inglês Optical Character Recognition (OCR) - e a capactiação para o uso de técnicas de OCR para reconhecimento de caracteres em imagens e PDF.

Para isso teremos um tutorial e um workshop sobre o programa gImageReader.

O gImageReader é um programa de código livre e aberto, gratuito, que é uma interface gráfica simples que utiliza o tesseract-ocr.

Seu objetivo é possibilitar diferentes estratégias para o reconhecimento de caracteres em diferentes tipos de arquivos.

Exemplo usando o Tesseract

Imagem de exemplo:

trinidad

# exemplo de OCR com Tesseract
import cv2 # é um módulo para manipulação de imagens
import pytesseract # é uma biblioteca para reconhecimento de texto

# carregar a imagem
img_path = 'img/IMG_4689.jpg'
# ler a imagem usando o módulo cv2
img = cv2.imread(img_path)

# aplicar o OCR sobre a imagem
text = pytesseract.image_to_string(img)

# exibir o texto
print(text)

# salvar o texto em um arquivo
with open('ex_ocr_img.txt', 'w') as f:
    f.write(text)
# fechar o arquivo
f.close()
     
   
  
  
   
  
   
 
    
  
 
  

Government House,

19th February, 1904.

sir,

I have the honour to forward for your
information a copy of a report upon the conduct of the
public and the police dubing the recent Carnival which

I think may be regarded as highly satisfactory.

Qe The importance of the matter lies wholly
in the fact that the manner in which the Carnival has
passed off may be regarded, I consider, as indicative
of a marked improvement in the state of general public

feeling in Port-of-Spain, both towards the Government

and towards the Police.

I have the honour to bes

Sir,

Your most obedient,

humble Servant,

hevliche a
Silane —

G Ov) 6s momen.

 


Tutorial - gImageReader (OCR para Windows 10)

from IPython.display import YouTubeVideo
YouTubeVideo("_7eqj01Hn0M", width=560, height=315)

Workshop de reconhecimento de caracteres com gImageReader

Os exemplos usados na aula podem ser acessados nos seguintes links:

  1. Jornal do Brasil, 28 de outubro de 2002, p.1

  2. Jornal do Brasil, 08 de janeiro de 1917, p.1

  3. Eugene D. Genovese - Da Rebelião à Revolução

Tarefa 4

  1. Assistar o tutorial de instalação do gImageReader;

  2. Instalar o programa no computador.