Skip to content

Latest commit

 

History

History
53 lines (34 loc) · 1.08 KB

4图像识别.md

File metadata and controls

53 lines (34 loc) · 1.08 KB

图像识别

网上教程

开源

  1. 安装
# ubuntu
sudo apt-get install tesseract-ocr
  1. 字库安装
  1. 训练字库
  1. 命令
tesseract test.png outfile -l chi_sim # 使用中文字库
  1. python代码
from PIL import Image
import pytesseract

class Languages:
    CHS = 'chi_sim'
    CHT = 'chi_tra'
    ENG = 'eng'

def img_to_str(image_path, lang=Languages.ENG):
    return pytesseract.image_to_string(Image.open(image_path), lang)
  
print(img_to_str('image/test1.png', lang=Languages.CHS))
print(img_to_str('image/test2.png', lang=Languages.CHS))

收费