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