Search code examples
c++opencvcomputer-visionocrtesseract

Example of OCRTesseract with OpenCV 3


I found that page about OCR using Tesseract on OpenCV 3.1. The problem is that given links include examples with older OpenCV versions. Is there any up to date example of usage of OCR Tesseract? and How can I told this to OpenCV authority?


Solution

  • The sample code below is unfortunately in Python with the text module/opencv_contrib of OpenCV 3.2. I compiled Tesseract 4.0.0alpha with OpenCV 3.2.0 binding to make it works few months ago. Hope this could be a reference for your C++ implementation.

    # para: tessdata path, language, whitelist, psm, oem
    tesser = cv2.text.OCRTesseract_create('C:/Program Files/Tesseract 4.0.0/tessdata/','eng',
               '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',11,3) 
    retval = tesser.run(processed_image, 0) # ' return string type
    

    As far as I know, the Text module doesn't work well in OpenCV 3.0/3.1. Would suggest to use 3.2.0 to avoid any possible issue on earlier 3.x versions.