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)

相关推荐
BU摆烂会噶3 分钟前
【LangGraph】持久化实现的三大能力——时间旅行
数据库·人工智能·python·postgresql·langchain
消失的旧时光-19431 小时前
统一并发模型:线程、Reactor、协程本质是一件事(从线程到协程 · 第6篇·终章)
java·python·算法
zhaoyong2223 小时前
MySQL 存储过程中字符集与排序规则不匹配导致查询性能下降的解决方案
jvm·数据库·python
sinat_383437363 小时前
golang如何从Python转型Go开发_golang从Python转型Go开发攻略
jvm·数据库·python
rockey6273 小时前
基于AScript的python3脚本语言发布啦!
python·c#·.net·script·python3·eval·expression·function·动态脚本
gqk013 小时前
Python入门
python
Muyuan19983 小时前
28.Paper RAG Agent 开发记录:修复 LLM Rerank 的解析、Fallback 与可验证性
linux·人工智能·windows·python·django·fastapi
代码小书生4 小时前
statistics,一个统计的 Python 库!
开发语言·python
STLearner4 小时前
SIGIR 2026 | LLM × Graph论文总结(图增强LLM,GraphRAG,Agent,多模态,知识图谱,搜索,推
人工智能·python·深度学习·神经网络·机器学习·数据挖掘·知识图谱
FreakStudio4 小时前
MicroPython 内核开发者直接狂喜!这个 Claude 插件市场,把开发全流程做成了「对话式外挂」
python·单片机·嵌入式·面向对象·并行计算·电子diy