2017-12-03 96 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