Created
August 27, 2018 14:04
-
-
Save ice2heart/ebd2b33bf80f708fec85ece8529e1e06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import sys | |
import pytesseract | |
import pyautogui | |
import numpy as np | |
import re | |
import imutils | |
if __name__ == '__main__': | |
# Define config parameters. | |
# '-l eng' for using the English language | |
# '--oem 1' for using LSTM OCR Engine | |
config = ('-l eng --oem 1 --psm 3') | |
pattern = re.compile(r"[a-zA-Z0-9]{5}") | |
while True: | |
# pyautogui.screenshot("test.png") | |
image = pyautogui.screenshot() | |
# Read image from disk | |
# im = cv2.imread(imPath, cv2.IMREAD_COLOR) | |
im = cv2.cvtColor(np.array(image), cv2.COLOR_RGB2BGR) | |
crop_img = im[900:925, 2370:3336] | |
# cv2.imshow("cropped", crop_img) | |
# cv2.waitKey(0) | |
text = pytesseract.image_to_string(crop_img, config=config) | |
for x in range(len(text) - 5): | |
t = text[x:x+5] | |
if pattern.match(t): | |
print('https://www.gog.com/redeem/{0}'.format(t)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment