B
B
BonBon Slick2022-02-03 20:39:19
Python
BonBon Slick, 2022-02-03 20:39:19

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


Docs that I used https://pypi.org/project/pytesseract/
https
://github.com/tesseract-ocr/tesseract/blob/ma...
https://github.com/tesseract-ocr/tessdoc

write some additional configs
https://muthu.co/all-tesseract-ocr-options/

issue description, but they did not help
https://github.com/tesseract-ocr/tesseract/issues/1196
https:// stackoverflow.com/questions/47104245/tesse...
https://www.mail-archive.com/[email protected]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Shevkunov, 2022-02-03
@danila763

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 question

Ask a Question

731 491 924 answers to any question