Search code examples
opencvpipocrtesseractpython-tesseract

pytesseract installed but missing?


x64, Win 10, Anaconda Python 2.7

I'm trying to do some OCR from captured video frames using OpenCV & pytesseract, my code...

import numpy as np
import cv2
from PIL import ImageGrab
import pytesseract

cap = cv2.VideoCapture(0)

while True:
   # orig_img = ImageGrab.grab(box)
    ret, orig_img = cap.read()

    np_im = np.array(orig_img)

    img = cv2.cvtColor(np_im, cv2.COLOR_BGR2GRAY)

    text = pytesseract.image_to_string(img)

    cv2.imshow('window',img)
    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()

    print(text)

I used pip install pytesseract but whenever I run the code I get the following errors..

  File "C:\ProgramData\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 309, in image_to_string
    }[output_type]()

  File "C:\ProgramData\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 308, in <lambda>
    Output.STRING: lambda: run_and_get_output(*args),

  File "C:\ProgramData\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 218, in run_and_get_output
    run_tesseract(**kwargs)

  File "C:\ProgramData\Anaconda2\lib\site-packages\pytesseract\pytesseract.py", line 186, in run_tesseract
    raise TesseractNotFoundError()

TesseractNotFoundError: tesseract is not installed or it's not in your path

And sure enough when I look in the pytesseract folder pytesseract.py or tesseact.exe or anything tesseract isn't there...

enter image description here

So even if I wanted to add it to my PATH I cant.

What am I missing here?


Solution

  • Have you installed Google Tesseract OCR? It's a pre-requisite for using pytesseract.

    If not all the instructions to do so are on it's GitHub page. https://github.com/tesseract-ocr/tesseract/wiki

    I hope this helps.