圖像識別

Python圖片識別漢字字母數字,tesseract-ocr

2018年03月09日 Python LEO 2607


        環境:ubuntu + python2.7

        代碼:

#/usr/bin/env python

# -*- coding: UTF-8 -*-

 

from PIL import Image

import pytesseract

text=pytesseract.image_to_string(Image.open('/root/Desktop/444.jpg'),lang='chi_sim')

print(text)

 

        效果:

444.jpg

1.png

2.png

        步驟:

                1:這裏我們需要用到兩個庫:pytesseract和PIL

                2:同時我們還需要安裝識別引擎tesseract-ocr

                3:下載中文簡體字庫chi_sim.traineddata

 

        安裝pytesseract和PIL

                pip install PIL 

                pip install pytesseract 

 

        安裝識別引擎tesseract-ocr

                安裝Tesseract

                sudo apt-get install tesseract-ocr

                安裝中文

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

 

        下載中文簡體字庫

                地址:https://download.csdn.net/download/leoeitail/10275552

                存放路勁:/usr/local/share/tessdata/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章