我试图通过图像识别传奇联盟游说团的文本,这样我就可以进行数据挖掘
我猜它无法识别字体,因为程序的输出是:Doel seen aay
源代码:
import numpy as nm
import pytesseract
import cv2
from PIL import ImageGrab, Image
def imToString():
# Path of tesseract executable
pytesseract.pytesseract.tesseract_cmd ='C:\\Program Files\\Tesseract-OCR\\Tesseract.exe'
while(True):
cap = ImageGrab.grab(bbox =(242, 884, 561, 990))
cap.save('test.png')
tesstr = pytesseract.image_to_string(
cv2.cvtColor(nm.array(cap), cv2.COLOR_BGR2GRAY),
lang ='eng',config='--psm 7')
print(tesstr)
imToString()
看起来你需要一些预处理来获得图像
试试这个
相关问题 更多 >
编程相关推荐