zoukankan      html  css  js  c++  java
  • ubuntu 安装 pytesseract 模块进行图片内容识别

    主要是实现图片内容的离线识别,python 提供了一个库完成此功能。

    一. 安装  tesseract-ocr 包

    sudo apt-get install tesseract-ocr

    二. 安装 PIL PIL(python imaging library)是python中的图像处理库

     sudo apt-get install python-imaging

    三.  安装 pytesseract

    pip install pytesseract

    四.代码测试

    # -*- coding: UTF-8 -*-
    from PIL import Image
    import pytesseract
    # 识别中文
    text = pytesseract.image_to_string(Image.open('chinese.png'),lang='chi_sim')
    print text

    # 识别英文
    text = pytesseract.image_to_string(Image.open('english.png'))
    print text

    五.要想识别的中文需要添加中文字库

    需要在ubuntu  系统中 找到 tessdata  文件夹把中文字库放进去

    也可以在线安装中文字库

    sudo apt-get install tesseract-ocr-chi-sim

    六.此模块还支持 命令行识别

    使用命令:
    识别英文:
    tesseract e.png 1   #1 是存储获取内容的文件,会在本地生成一个1文件
    识别中文
    tesseract --help  # 查看帮助
    tesseract --list -langs  # 查看是否安装了中文库chi_sim
    tesseract -l chi_sim c.png 1 # 1也是结果的文件把识别的结果存到此文件中

    还可以离线安装源码编译安装 参考的教程

    https://www.cnblogs.com/yanhai307/p/10791490.html
    
    
  • 相关阅读:
    xml/xslt常用转义字符
    用ScriptManager实现Web服务的异步调用
    声明静态方法和实例方法的原则
    http request header 中的host行的作用
    获取客户端数据
    HTTP 处理程序(HttpHandlers)
    display与visibility
    会话管理
    ASP.NET 管道
    HttpContext, HttpRequest, HttpResponse
  • 原文地址:https://www.cnblogs.com/wanghuixi/p/12230224.html
Copyright © 2011-2022 走看看