fork download
  1. # your code goes here
  2.  
  3. import cv2 as cv
  4. import pytesseract
  5.  
  6. image_path = "screenshot.png"
  7. image = cv.imread(image_path, cv.IMREAD_GRAYSCALE)
  8. _, modified_image = cv.threshold(image, 64, 255, cv.THRESH_BINARY)
  9.  
  10. cv.imwrite("modified_image.png", modified_image)
  11. custom_config = r'--psm 12 --oem 1 -c tessedit_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.:'
  12. pytesseract.pytesseract.tesseract_cmd = 'C:\Tesseract-OCR\tesseract.exe'
  13. text = pytesseract.image_to_string("modified_image.png", config=custom_config, lang="eng")
  14.  
  15. print(f'Text: {text}')
  16.  
Runtime error #stdin #stdout #stderr 0.17s 25704KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 3, in <module>
ModuleNotFoundError: No module named 'cv2'