Search code examples
pythonjupyter-notebooktiffeasyocr

Working with TIFF in Python using EasyOCR


I use a Python Module EasyOCR for extracting text from image. This Method works for PNG Format but in TIFF Situation give me a error

Code look like this:

import easyocr 
import cv2
from matplotlib import pyplot as plt
import numpy as np 

IMAGE_PATH = 'IMG_4022.tif'

reader = easyocr.Reader(['en'], gpu=False)
result = reader.readtext(IMAGE_PATH)
result

I work with Juypter Notebook


Solution

  • You are not reading the image. Please use opencv to read the image. Ensure that the image is in the current directory or provide the absolute path of the image.

    from easyocr import Reader 
    import cv2
    from matplotlib import pyplot as plt
    import numpy as np 
    
    IMAGE_PATH = "IMG_4022.tif"
    image = cv2.imread(IMAGE_PATH)
    
    languages = ['en']
    
    reader = Reader(languages, gpu = False)
    results = reader.readtext(image)