简体   繁体   中英

pytesseract: convert pictures of 7-segment numbers to text

I'm trying to convert pictures like this: 7-segment into text with pytesseract:

7段

I tried different PSM modes and a whitelist with only 0123456789, but the best output of pytesseract was '5' instead of '125'.

Is there a way to configure pytesseract in way that it can convert my pictures? Or are there any extensions?

Thank you.

import pytesseract
from PIL import Image, ImageTk

img = Image.open('test.png')

text = pytesseract.image_to_string(img, config=("-c tessedit_char_whitelist=0123456789 --psm 7"))

print(text)
  1. Read and follow docs
  2. Use letsgodigital as ocr "language"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM