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)

相关推荐
树獭非懒1 天前
AI大模型小白手册|Embedding 与向量数据库
后端·python·llm
唐叔在学习2 天前
就算没有服务器,我照样能够同步数据
后端·python·程序员
曲幽2 天前
FastAPI流式输出实战与避坑指南:让AI像人一样“边想边说”
python·ai·fastapi·web·stream·chat·async·generator·ollama
Flittly2 天前
【从零手写 AI Agent:learn-claude-code 项目实战笔记】(1)The Agent Loop (智能体循环)
python·agent
vivo互联网技术2 天前
ICLR2026 | 视频虚化新突破!Any-to-Bokeh 一键生成电影感连贯效果
人工智能·python·深度学习
敏编程2 天前
一天一个Python库:virtualenv - 隔离你的Python环境,保持项目整洁
python
喝茶与编码2 天前
Python异步并发控制:asyncio.gather 与 Semaphore 协同设计解析
后端·python
zone77392 天前
003:RAG 入门-LangChain 读取图片数据
后端·python·面试
用户8356290780512 天前
在 PowerPoint 中用 Python 添加和定制形状的完整教程
后端·python