Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import keyboard
- import cv2
- import mss
- import numpy
- import pytesseract
- time.sleep(5)
- with mss.mss() as sct:
- # Part of the screen to capture
- monitor = {"top": 490, "left": 300, "width": 800, "height": 130}
- while "Screen capturing":
- # Get raw pixels from the screen, save it to a Numpy array
- img = numpy.array(sct.grab(monitor))
- # Display the picture
- cv2.imshow("OpenCV/Numpy normal", img)
- #keyboard.write(s[0:2])
- # Display the picture in grayscale
- # cv2.imshow('OpenCV/Numpy grayscale',
- # cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY))
- # Press "q" to quit
- if cv2.waitKey(25) & 0xFF == ord("q"):
- cv2.destroyAllWindows()
- break
- # Part of the screen to capture
- s = pytesseract.image_to_string(img, lang='rus')
- print(s)
- i = 0
- while i < len(s):
- if s[i] == "\n":
- keyboard.write(' ')
- i += 1
- continue
- keyboard.write(s[i])
- i += 1
- print(s)
- # Display the picture in grayscale
- # cv2.imshow('OpenCV/Numpy grayscale',
- # cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY))
- # Press "q" to quit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement