2017-12-03 155 views

回答

0

您可以使用正方体代替,因为它具有读取文本功能垂直对齐,以及: 这里是一个示例代码:

import Image 
import pytesseract 
# provide the cropped area with text 
def GetOCR(tempFilepath,languages ='eng'): 
    img = Image.open(tempFilepath) 
    #img= img.convert('L') 
    # filters can be applied optionally for reading the proper text from the image 
    img.load() 
    # -psm 5 will assume the text allinged vertically 
    text = pytesseract.image_to_string(img,lang = languages,config='-psm 6') 
    print "text :{0}".format(text) 

注:上述样品将工作,前提是你要有pytesseract模块安装和tesseract-ocr exe安装在您的机器上。 希望这有助于:)

+0

我想我必须培养正方体,以确定那些文字,是有可能做到这一点在树莓派 – cms

+0

是的,你可以有你自己的训练数据 - 这是一个耗时的过程,但这可能不适用于您的场景,如果您可以在图像上应用一些过滤器,您可以轻松获得结果。因为在这种情况下,你已经获得了90 +%的准确度 – csharpcoder