tesseract : how to use user words python

Viewed 98

I am using Tesseract in my python application, and i would use only my own dictionary.

I tried to do it with bazaar explanation but i did't understand how to do it ?!!

I did't find python commands to do this , here is my code :

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()

could any one explain to me step by step how to use only my words ? or maybe modify trained files ?

0 Answers
Related