Search code examples
ocrtesseract

Is there any solution for mix language problem in tesseract 4.1.1?


I want to covert image to text with tesseract engine. Input image has two language(persian and english). When I use tesseract multi language feature(fas+eng), converted text has many error. For example: input image

output:

BERT Joo‏ و استفاده از آن در این گزارش به تعریف مفاهیم مورد نیاز برای شناخت مدل 7۳11 می‌پردازيم و نحوه استفاده از آن را برای تحلیل متن توضیح می‌دهیم.

Should I train model with persian and english text?


Solution

  • You must update to latest version of tesseract OR fas trainned data.

    I use this version of tesseract:

    # tesseract.exe --version
    tesseract v5.0.0-alpha.20191030
     leptonica-1.78.0
      libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.3) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.0
     Found AVX
     Found SSE
     Found libarchive 3.3.2 zlib/1.2.11 liblzma/5.2.3 bz2lib/1.0.6 liblz4/1.7.5
    

    And also I use this commit version for fas train data:
    https://github.com/tesseract-ocr/tessdata/blob/cdd8a9ec438fc0b9f21635466196fe1c05efca16/fas.traineddata

    And I use this command:

    tesseract.exe image.png out -l fas+eng
    

    So as you can see in here, We have this correct text:

    مدل ‎BERT‏ و استفاده از آن
    در این گزارش به تعریف مفاهیم مورد نیاز برای شناخت مدل ‎BERT‏ می‌پردازيم و نحوه استفاده از
    
    آن را برای تحلیل متن توضیح می‌دهیم.
    

    Also see this image: enter image description here