Pytesseract, trying to detect text from on screen
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn
--
Track title: CC G Dvoks String Quartet No 12 Ame 2
--
Chapters
00:00 Question
03:17 Accepted answer (Score 6)
03:59 Thank you
--
Full question
https://stackoverflow.com/questions/4811...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #numpy #pytesser #pythonmss
#avk47
--
Track title: CC G Dvoks String Quartet No 12 Ame 2
--
Chapters
00:00 Question
03:17 Accepted answer (Score 6)
03:59 Thank you
--
Full question
https://stackoverflow.com/questions/4811...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #numpy #pytesser #pythonmss
#avk47
ACCEPTED ANSWER
Score 6
I can get this code working:
import time
import cv2
import mss
import numpy
import pytesseract
mon = {'top': 0, 'left': 0, 'width': 150, 'height': 150}
with mss.mss() as sct:
while True:
im = numpy.asarray(sct.grab(mon))
# im = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)
text = pytesseract.image_to_string(im)
print(text)
cv2.imshow('Image', im)
# Press "q" to quit
if cv2.waitKey(25) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
# One screenshot per second
time.sleep(1)
The sleep time may be a good thing to not explode your CPU.