1

I'm using pytesser on simple images with plain text. It works great! However, in python it prints each line of text on a new line. But the string it outputs has no "\n" or new line delimiters that I can pull out.

How does it print each new line of the image on a new line in the console? And is there a way I can pull out a particular line? or split them myself?

It's more than likely something very simple i'm missing...

from pytesser import *
image = Image.open('image.jpg') 

text =  image_to_string(image)

print len(text)
print text 

Output:

983
BACK RASHER 1.24
T CREAM 250ML 1.19
T COFFEE 200G 1.09
PEANUT BUTTER 1.12
DIET COKE * 2.39
4

1 回答 1

0

感谢 指出我的错误。repr() 显示interpeter 看到的输出,以及新行“\n”分隔符。使用 text.split("\n") 然后我可以逐行拆分输出。谢谢dlask!

from pytesser import *
image = Image.open('image.jpg')  # Open image object using PIL

text =  image_to_string(image)     # Run tesseract.exe on image

print(repr(text))
result = text.split("\n")

print result
于 2015-05-27T15:21:56.713 回答