trasseract Unsupported image object

Question:

I learning python and I want read a document but ones words are diferent. I use this code,

pytesseract.pytesseract.tesseract_cmd = r'C:Program Files (x86)Tesseract-OCRtesseract'

img = cv2.imread('tes_palabra.png')

words = pytesseract.image_to_string(img)

print(words)

image used and required is https://ibb.co/KscWbD3

but return Unsupported image object

Asked By: stick

||

Answers:

Try somethink like this, using Image module from PIL:

from PIL import Image 
import pytesseract

pytesseract.pytesseract.tesseract_cmd = r'C:Program Files (x86)Tesseract-OCRtesseract'

img_file = r'tes_palabra.png'
img = Image.open(img_file)
words = pytesseract.image_to_string(img)

print(words)
Answered By: Leonid Rusanov
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.