Answer the question
In order to leave comments, you need to log in
Why doesn't the program output anything to the command line?
Hello, I am a very strong python newbie. Faced such a problem, when looping the script, the text from the screen should be output to the console in real time, with any change, but this does not happen, although the script works. Screenshots are taken with this no problem. If the script is not looped, then the text is displayed once and everything is fine with that.
import time
import numpy as np
import pyscreenshot as ImageGrab
import cv2
import os
import pytesseract
import re
filename = 'Image.png'
x = 1
last_time = time.time()
while(True):
screen = np.array(ImageGrab.grab(bbox=(0, 680, 454, 1007)))
#print('loop took {} seconds'.format(time.time()-last_time))
last_time = time.time()
#cv2.imshow('window',cv2.cvtColor(screen, cv2.COLOR_BGR2RGB))
cv2.imwrite(filename, screen)
x = x + 1
#print(x)
#if x == 2:
#cv2.destroyAllWindows()
#break
img = cv2.imread('Image.png')
pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe'
text = pytesseract.image_to_string(img)
print(text)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question