Answer the question
In order to leave comments, you need to log in
TesseractError 1, 'Error in pixCreateNoInit: pix_malloc fail for data Error in pixCreateTemplateNoInit: pixd not made Error in pixCreateTemplate?
File "C:\Users\BonBon.DESKTOP-B1B9CUP\Downloads\Check_Images_Similarity_PY\check.py", line 55, in isImageHasText
text: string = pytesseract.image_to_string(Image.open(fileNamePath)).strip() or ''
File "C:\Users\BonBon.DESKTOP-B1B9CUP\AppData\Local\Programs\Python\Python310\lib\site-packages\pytesseract\pytesseract.py", line 413, in image_to_string
return {
File "C:\Users\BonBon.DESKTOP-B1B9CUP\AppData\Local\Programs\Python\Python310\lib\site-packages\pytesseract\pytesseract.py", line 416, in <lambda>
Output.STRING: lambda: run_and_get_output(*args),
File "C:\Users\BonBon.DESKTOP-B1B9CUP\AppData\Local\Programs\Python\Python310\lib\site-packages\pytesseract\pytesseract.py", line 284, in run_and_get_output
run_tesseract(**kwargs)
File "C:\Users\BonBon.DESKTOP-B1B9CUP\AppData\Local\Programs\Python\Python310\lib\site-packages\pytesseract\pytesseract.py", line 260, in run_tesseract
raise TesseractError(proc.returncode, get_errors(error_string))
pytesseract.pytesseract.TesseractError: (
1,
'Error in pixCreateNoInit: pix_malloc fail for data Error in
pixCreateTemplateNoInit: pixd not made Error in pixCreateTemplate: pixd not made Error in
pixCopy: pixd not made Error in pixGetDepth: pix not defined Error in
pixGetWpl: pix not defined Error in pixGetYRes: pix not defined
Please call SetImage before attempting recognition.
Error during processing.
')
from pytesseract import *
import cv2
from PIL import ImageFile, Image
ImageFile.LOAD_TRUNCATED_IMAGES = True
pytesseract.tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe'
def isImageHasText(fileNamePath: string) -> bool:
pytesseractConfig = r'--oem 3 --psm 6'
text: string = pytesseract.image_to_string(Image.open(fileNamePath), config=pytesseractConfig).strip() or ''
hasText: bool = 0 != len(text)
return hasText
Answer the question
In order to leave comments, you need to log in
Try to put it like this:
1) pip install pytesseract
2) Download the installer here and install it, remembering to select the required languages for recognition (Additionaly languge data)
3) Recognize English text
import pytesseract
from PIL import Image
pytesseract.pytesseract.tesseract_cmd = "C:/Program Files/Tesseract-OCR/tesseract.exe"
image = Image.open("test.png")
print(pytesseract.image_to_string(image, lang='eng'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question