python3 識別圖片文字


  1、下載相關組件

    安裝:pip install Pillow 或下載:https://pypi.org/project/Pillow/5.2.0/  ,https://pypi.org/project/Pillow/5.2.0/#filesPillow-5.2.0-cp36-cp36m-win_amd64.whl

       下載后:在C:\Python36\Scripts目錄下:pip install Pillow-5.2.0-cp36-cp36m-win_amd64.whl

    安裝:pip3 install pytesseract   或下載安裝:pytesseract-0.2.4.tar.gz 或 https://pypi.org/project/pytesseract/#files

 

    下載:tesseract-ocr-w64-setup-v4.0.0-beta.1.20180608.exe 安裝,參見:圖片文字OCR識別-tesseract-ocr

  2、實例程序

    

#coding:utf8
import os
from PIL import Image
import pytesseract

file=r"D:\work\python36_crawl\pictureParser\中文.png"
# file=r"D:\work\python36_crawl\pictureParser\英文.png"
if os.path.exists(file):
    image = Image.open(file)
    # 英文
    # vcode = pytesseract.image_to_string(image,"eng")
    vcode = pytesseract.image_to_string(image, "chi_sim")
    print(vcode)

 

 驗證碼相關鏈接:https://zhuanlan.zhihu.com/p/30871712


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM