Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pytesseract
- import cv2
- import numpy as np
- from PIL import Image, ImageGrab
- from matplotlib import pyplot as plt
- x = 645
- y = 575
- x_offset = 1220
- y_offser = 180
- replacements = (('1', 'l'), ('0', 'o'))
- while True:
- img = ImageGrab.grab(bbox=(x, y, x + x_offset, y + y_offser)).convert('L')
- img = np.array(img)
- img = cv2.GaussianBlur(img, (5, 5), 0)
- img = cv2.threshold(img, 120, 255, cv2.THRESH_BINARY)[1]
- cv2.imshow('window', img)
- text = pytesseract.image_to_string(img).replace(" ", "").lower()
- for old, new in replacements:
- text = text.replace(old, new)
- if text is not "":
- print(text)
- if "champion" in text:
- print("Winner winner")
- cv2.waitKey(0)
- break
- if cv2.waitKey(250) & 0xFF == ord('q'):
- cv2.destroyAllWindows()
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement