python pytesseract库,ocr

pytesseract

  • 安装pytesseract-ocr

    mac:

    python 复制代码
    //先安装依赖库libpng, jpeg, libtiff, leptonica
    brew install leptonica
    
    //安装tesseract的同时安装训练工具
    brew install --with-training-tools tesseract
    
    //安装tesseract的同时安装所有语言,语言包比较大,如果安装的话时间较长,建议不安装,按需选择
    brew install  --all-languages tesseract
    
    //安装tesseract,并安装训练工具和语言
    brew install --all-languages --with-training-tools tesseract 
    
    //只安装tesseract,不安装训练工具
    brew install  tesseract

    win:

    安装包地址:https://github.com/UB-Mannheim/tesseract/wiki

    配置环境变量

    安装依赖包:

    pip install pytesseract

    pip install pillow

  • 下载语言库

    chi_sim.traineddata:中文简体

    eng.traineddata:英文

    https://github.com/tesseract-ocr/tessdata

  • 使用

    python 复制代码
    from PIL import Image
    import pytesseract
    text = pytesseract.image_to_string(Image.open('./eng.png')
                                       ,lang='eng' # 指定语言,chi_sim为简体中文
                                      )
    print(text)

相关推荐
无垠的广袤7 小时前
【工业树莓派 CM0 Dev Board】扩展板设计
linux·python·嵌入式硬件·pcb设计·模块化·传感器
Yolanda_20228 小时前
在vscode终端中可使用pip,但是cmd终端中找不到命令 pip问题的解决
vscode·python·conda·pip
2301_764441338 小时前
用动力学系统(微分方程)为 Kernberg 的客体关系单元提供数学化的操作定义,把“自体—客体“这对心理结构建模成一个二维耦合系统
数据结构·python·算法·数学建模
dogstarhuang8 小时前
用 Doubao-Seed-Evolving + Python 免费写一个网页正文提取工具(实战教程)
爬虫·python·ai编程
猫头虎9 小时前
什么是ZCode for GLM-5.2?
开发语言·人工智能·python·科技·算法·ai编程·ai写作
心运软件9 小时前
Python实战:中国大学排行榜数据采集与可视化大屏
后端·python
长不胖的路人甲9 小时前
什么是赫夫曼树(哈夫曼树 / Huffman Tree)
python·算法·霍夫曼树
魔镜er10 小时前
03-张量
人工智能·pytorch·python
37.2℃99510 小时前
Claude Design哪个公司技术好
python·设计模式
1570925113410 小时前
【无标题】
开发语言·python·算法