这是我的程序,从图像程序中提取文本:
import pytesseract
from PIL import Image
import os
from os.path import join
import sys
con_1 = True
store_1 = []
store_2 = []
store_3 = []
con_1 = True
print("Welcome to my Text Extraction from Image Program. Here you can extract text from any image.")
while con_1:
image_name = input("Enter your image's name:")
for root, dirs, files in os.walk("/home/"):
if image_name in files:
found = join(root, image_name)
store_1.append(found)
if len(store_1) == 0:
ask_1 = str(input("Your image was not found. Do you want to try again(Y/n)?:"))
if ask_1 == "Y" or ask_1 == "y":
con_1 = True
elif ask_1 == "N" or ask_1 == "n":
con_1 = False
else:
print("Your input is out of bounds. Please try again.")
else:
print("Your image was successfully found.")
image_open = Image.open(found)
image_text = pytesseract.image_to_string(image_open)
print(image_text)
break
这是我见过的最奇怪的输出:
‘Understanding how computer memory
ia tire terrae tec
programming lan
另一个非常奇怪的输出:
Sesh chee nia ec Hiok pc
RU hun oe
mete een
machines work while still being easy to learn.
我从未见过我的程序给我如此偏离目标和奇怪的输出。我完全不知道这是怎么回事。我非常想知道如何修复它以及为什么我的程序出现故障。