美文网首页Python 学习
Python 进行 OCR识别 -- pytesseract库

Python 进行 OCR识别 -- pytesseract库

作者: bianruifeng | 来源:发表于2021-03-17 16:54 被阅读0次
    pip3 install pytesseract
    brew install tesseract
    

    资源文件:


    image.png image.png

    创建py文件:

    import pytesseract
    from PIL import Image
    
    im_en = Image.open('English.png')
    im_ch = Image.open('Chinese.png')
    
    print('========识别字母========')
    print(pytesseract.image_to_string(im_en), '\n\n')
    
    print('========识别中文========')
    print(pytesseract.image_to_string(im_ch, lang='chi_sim'))
    

    运行报错:
    找不到/usr/local/Cellar/tesseract/4.1.1/share/tessdata/chi_sim.traineddata文件
    下载:

    识别中文需要新的字库

    运行结果:


    image.png

    百度的OCR https://cloud.baidu.com/doc/OCR/s/zk3h7xw5e

    相关文章

      网友评论

        本文标题:Python 进行 OCR识别 -- pytesseract库

        本文链接:https://www.haomeiwen.com/subject/sfeecltx.html