I want to build project that reads texts continuously from part of my pc screen and shows them on the console of pycharm
I am using python 3, all modules are installed using pip from pycharm console.
I used this code:
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)
got this error which I couldn't deal with :
C:\Users\ali91\PycharmProjects\OCR\venv\Scripts\python.exe
"C:/Users/ali91/PycharmProjects/OCR/lesson 1.py" Traceback (most
recent call last): File
"C:\Users\ali91\PycharmProjects\OCR\venv\lib\site-packages\pytesseract\pytesseract.py",
line 252, in run_tesseract
proc = subprocess.Popen(cmd_args, **subprocess_args()) File "C:\Program Files\Python39\lib\subprocess.py", line 947, in __init__
self._execute_child(args, executable, preexec_fn, close_fds, File "C:\Program Files\Python39\lib\subprocess.py", line 1416, in
_execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args, FileNotFoundError: [WinError 2] The system cannot find the file
specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\ali91\PycharmProjects\OCR\lesson 1.py", line 15, in <module>
text = pytesseract.image_to_string(im) File "C:\Users\ali91\PycharmProjects\OCR\venv\lib\site-packages\pytesseract\pytesseract.py",
line 413, in image_to_string
return { File "C:\Users\ali91\PycharmProjects\OCR\venv\lib\site-packages\pytesseract\pytesseract.py",
line 416, in <lambda>
Output.STRING: lambda: run_and_get_output(*args), File "C:\Users\ali91\PycharmProjects\OCR\venv\lib\site-packages\pytesseract\pytesseract.py",
line 284, in run_and_get_output
run_tesseract(**kwargs) File "C:\Users\ali91\PycharmProjects\OCR\venv\lib\site-packages\pytesseract\pytesseract.py",
line 256, in run_tesseract
raise TesseractNotFoundError() pytesseract.pytesseract.TesseractNotFoundError: tesseract is not
installed or it's not in your PATH. See README file for more
information.