Python Pytesseract - 无法读取图像

时间:2021-05-30 16:32:37

标签: python ocr python-tesseract

我是 pyteseract OCR 的新手。我能够阅读简单的图片并获得测试消息。我无法从附加的 png 文件中读取测试。从附加的图像中,我试图在文本中提取 ishSilver 和 (SLV)。 如果您能对此提供帮助,我将不胜感激。提前致谢。

from PIL import Image
import pytesseract

pytesseract.pytesseract.tesseract_cmd = r'C:\Tesseract-OCR\tesseract.exe' # actual path to tesseract
im = Image.open('Images/' + '1680.png')
            # Size of the image in pixels (size of orginal image)
            # (This is not mandatory)
width, height = im.size

# Setting the points for cropped image
left = width*.88
top = 0
right = width
bottom = height 

# Cropped image of above dimension
# (It will not change orginal image)
im1 = im.crop((left, top, right, bottom))

# Capturing the image in image viewer and converting to text
text = pytesseract.image_to_string(im1, lang="eng")
print(text)
print("/n")
# Finding the "(" and ")" to the actual stock ticker and save the text in symbol for placeorder to access the file
ticker = text[text.find("(")+1:text.find(")")]
print(ticker)

enter image description here

enter image description here enter image description here

0 个答案:

没有答案