Hi,

I think you need the config parameter, for example:

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

Best,

art

From: [email protected] <[email protected]> On Behalf 
Of Robert Edney
Sent: Monday, April 25, 2022 11:52 PM
To: tesseract-ocr <[email protected]>
Subject: [tesseract-ocr] New to Tesseract -- quick question

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!
--
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 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tesseract-ocr/434d9c50-ccad-46fd-adde-0abead8d9f40n%40googlegroups.com<https://groups.google.com/d/msgid/tesseract-ocr/434d9c50-ccad-46fd-adde-0abead8d9f40n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tesseract-ocr/YT3PR01MB9897BE132AB1303C4761F1F1DCFB9%40YT3PR01MB9897.CANPRD01.PROD.OUTLOOK.COM.

Reply via email to