In this article you will learn how to use pytesseract to recognize characters from a given image. This article is belong to optical character recognition (OCR) using tesseract python library.
tesseract is not installed or it's not in your PATH
Sometime when you are using pytesseract to recognize OCR you are facing below error.
pytesseract.pytesseract.TesseractNotFoundError: tesseract is not installed or it's not in your PATH.
Steps to resolve TesseractNotFoundError
To resolve this issue follow below steps.
- Download and Install latest version of tesseract (https://github.com/UB-Mannheim/tesseract/wiki)
- py -m pip install pytesseract (Run this command to install pytesseract)
- Set environment variable (Add this path to environment variable "C:\Program Files\Tesseract-OCR")
- Set the tesseract path in the script before calling image_to_string() function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import numpy as np | |
import pytesseract | |
# use line no 6 code in your script before calling image_to_string method | |
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe" | |
image = cv2.imread('google.jpg') | |
text = pytesseract.image_to_string(image, lang='eng', config='--psm 6 --oem 3 -c tessedit_char_whitelist= ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') | |
print('****text****',text) |
0 Comments