xxxxxxxxxx
import numpy as np
import cv2
from PIL import ImageGrab as ig
import pytesseract
from pytesseract import Output
pytesseract.pytesseract.tesseract_cmd = r'Path to your tesseract-OCR'
def screencap():
while(True):
screen = np.array(ig.grab(bbox=(x_co1,y_co1,x_co2,y_co2)))
gray = cv2.cvtColor(screen,cv2.COLOR_RGB2GRAY)
cv2.imshow("test", gray)
if cv2.waitKey(25) & 0xFF == ord('e'):
cv2.destroyAllWindows()
break
image_data = pytesseract.image_to_string(screencap())
print(image_data)
#Not sure how to edit the code from here. Only sees the screen but does not output your answer.
xxxxxxxxxx
# cv2.cvtColor takes a numpy ndarray as an argument
import numpy as nm
import pytesseract
# importing OpenCV
import cv2
from PIL import ImageGrab
def imToString():
# Path of tesseract executable
pytesseract.pytesseract.tesseract_cmd ='**Path to tesseract executable**'
while(True):
# ImageGrab-To capture the screen image in a loop.
# Bbox used to capture a specific area.
cap = ImageGrab.grab(bbox =(700, 300, 1400, 900))
# Converted the image to monochrome for it to be easily
# read by the OCR and obtained the output String.
tesstr = pytesseract.image_to_string(
cv2.cvtColor(nm.array(cap), cv2.COLOR_BGR2GRAY),
lang ='eng')
print(tesstr)
# Calling the function
imToString()