python——識別圖中文字


純干貨直接上代碼

百度:

    from aip import AipOcr

    config = {
        'appId': '',
        'apiKey': '',
        'secretKey': ''
    }

    client = AipOcr(**config)

    def get_file_content(file):
        with open(file, 'rb') as fp:
            return fp.read()

    def img_to_str(image_path):
        image = get_file_content(image_path)
        image = image.content
        result = client.basicAccurate(image)
        if 'words_result' in result:
            return '\n'.join([w['words'] for w in result['words_result']])

谷歌:

# open image
    image = Image.open('')
    code = pytesseract.image_to_string(image, lang='chi_sim')
    print(code)

 

參考

↓↓↓↓↓↓↓

 

看這里


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM