You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtesserocrfromPILimportImageimage=Image.new('RGB', (100, 100), 255)
withtesserocr.PyTessBaseAPI(r"C:\Program Files\Tesseract-OCR\tessdata", 'chi_sim', 10) asapi:
print(api.SetImage(image))
print(api.GetTextDirection()) # comment this line out will make python not crashprint(api.MapWordConfidences())
additional:
even if the image has a character in and GetUTF8Text() returned the result, the MapWordConfidences() still returns empty [] if there's a DetectOS() before it.
The error in your output is in tesseract not tesserocr but it's worth noting that Recognize() should be called before calling AllWords(), otherwise it'll always return an empty list (according to the method's docstring).
importtesserocrfromPILimportImageimage=Image.new('RGB', (100, 100), 255)
withtesserocr.PyTessBaseAPI(r"C:\Program Files\Tesseract-OCR\tessdata", 'chi_sim', 10) asapi:
print(api.SetImage(image))
api.Recognize()
print(api.GetTextDirection()) # comment this line out will make python not crashprint(api.MapWordConfidences())
output:
additional:
even if the image has a character in and
GetUTF8Text()
returned the result, theMapWordConfidences()
still returns empty[]
if there's aDetectOS()
before it.version:
tesseract 5.3.1
leptonica-1.83.1 (Jun 13 2023, 19:19:21) [MSC v.1935 LIB Release x64]
libgif 5.2.1 : libjpeg 6b (libjpeg-turbo 2.1.4) : libpng 1.6.39 : libtiff 4.5.0 : zlib 1.2.13 : libwebp 1.3.0 : libopenjp2 2.5.0
python 3.11.2
The text was updated successfully, but these errors were encountered: