tesseract.py 378 B

12345678910111213
  1. import cv2 as cv
  2. import pytesseract as pts
  3. pts.pytesseract.tesseract_cmd = "C:\\Program Files\\Tesseract-OCR\\tesseract.exe"
  4. img = cv.imread("kolya.png")
  5. img = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
  6. ret, threshold_image = cv.threshold(img, 127, 255, 0)
  7. cv.imshow("result", img)
  8. cv.waitKey(0)
  9. config = r'--oem 3 --psm 6'
  10. print(pts.image_to_string(img, lang="rus", config=config))