New to Tesseract -- quick question

80 views
Skip to first unread message

Robert Edney

unread,
Apr 25, 2022, 11:53:49 PM4/25/22
to tesseract-ocr
Hi All,
I have a very simple Python program running that works for everything but what I need to do.  I need Tesseract to recognize a single character.  I've read up about this, which has served to confuse me further.  Here's my code:

from PIL import Image
import pytesseract
img = Image.open('/home/pi/Desktop/typeset.jpg')
text = pytesseract.image_to_string(img)
#tesseract number.png stdout --psm 10
print(text)


The "typeset.jpg" is a single character, and Tesseract ignores it.  If I sub the image with one with two characters (or more), it works.

You can see that I've commented out "tesseract number.png stdout --psm 10" because it throws a syntax error.  My understanding is that I need that line to get Tesseract to create one box and read one character -- but I can't figure out how to make that work -- where to put it or any needed code with it -- and I've tried!

Thanks in advance for any help!

Art Rhyno

unread,
Apr 26, 2022, 1:13:34 PM4/26/22
to tesser...@googlegroups.com

Hi,

 

I think you need the config parameter, for example:

 

text = pytesseract.image_to_string(img, config='--psm 10')

 

Best,

 

art

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/434d9c50-ccad-46fd-adde-0abead8d9f40n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages