learning_notes

学习笔记

View project on GitHub

图像识别

网上教程

开源

Tesseract-OCR

  1. 安装
    # ubuntu
    sudo apt-get install tesseract-ocr
    
  2. 字库安装
  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))

收费