Issue
I'm attempting to image recognize the text from a league of legends lobby so I can data mine.
I guess it's not recognizing the font, as the output of the program is: Doel seen aay
Source code:
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()
Solution
It seems you need some preprocessing to image.
Try this one.
import numpy as np
import cv2
img = cv2.imread('wXQMF.png', 0)
print(img.max(), img.min())
ret, thr1 = cv2.threshold(img, 10, 255, cv2.THRESH_BINARY_INV)
kernel_size_row = 3
kernel_size_col = 3
kernel = np.ones((3, 3), np.uint8)
erosion_image = cv2.erode(thr1, kernel, iterations=1) #// make erosion image
cv2.imwrite('a.png',thr1)
Answered By - puhuk
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.