首页 > 解决方案 > tesseract:如何使用用户词 python

问题描述

我在我的 python 应用程序中使用 Tesseract,我只会使用我自己的字典。

我试图用集市解释来做,但我不明白该怎么做?!

我没有找到执行此操作的 python 命令,这是我的代码:

import cv2
import pytesseract as tess
tess.pytesseract.tesseract_cmd = r'C:\Users\Utilisateur\AppData\Local\Programs\Tesseract-OCR\tesseract.exe'

def ocr(img):
    cv2.imwrite('image.png', img)
    img = cv2.medianBlur(img, 1)
    img  = cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, \
                                cv2.THRESH_BINARY, 31, 20)
  
    cv2.imshow('frames', img)
    text = tess.image_to_string(img , lang='fra+eng') #config='bazaar'

    print(text)

vid = cv2.VideoCapture(0)
while (True):

    ret, frame = vid.read()
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) % 256 == 32:
       ocr(frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

vid.release()
cv2.destroyAllWindows()

谁能一步一步地向我解释如何只使用我的话?或者也许修改训练有素的文件?

标签: pythonocrtesseract

解决方案


推荐阅读