Notes, for myself, installing on Ubuntu. I attempting to follow the excellent guide found in this LSTM tutorial by Vaibhaw Singh Chandel.
Currently in beta, Tesseract 4 seems to be a nice improvement upon version 3.
sudo add-apt-repository ppa:alex-p/tesseract-ocr
sudo apt-get update
sudo apt install tesseract-ocr tesseract-ocr-eng
sudo pip install pytesseract
tesseract samples/inventory.png stdout -l eng --oem 1 --psm 3
Very simple example from great tutorial mentioned above.
import cv2
import sys
import pytesseract
if __name__ == '__main__':
if len(sys.argv) < 2:
print('Usage: python ocr_simple.py image.jpg')
sys.exit(1)
imPath = sys.argv[1]
config = ('-l eng --oem 1 --psm 3')
im = cv2.imread(imPath, cv2.IMREAD_COLOR)
text = pytesseract.image_to_string(im, config=config)
print(text)
First test with a fairly clear scan went well:
Second test with a much poorer scan had a lot more trouble:
Overall, I’m quite impressed with the improvements made in Tesseract’s new LSTM mode. Definitely a worthwhile tool for those doing OCR these days.