安装环境:windows10+python3.6+easyocr
备:python高版本可能会安装不上的情况
一、安装easyocr
pip install easyocr
二、下载模型
文字检测模型(CRAFT)(必须)
https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/craft_mlt_25k.zip
中文(简体)模型(识别中文必须)
https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/chinese_sim.zip
中文(繁体)模型
https://github.com/JaidedAI/EasyOCR/releases/download/pre-v1.1.6/chinese.zip
下载好解压以后放到 C:\Users******.EasyOCR\model
三、开始识别
import easyocr
def get_text(path):
text_list = []
# 创建reader对象
reader = easyocr.Reader(['ch_sim', 'en'])
# 读取图像
result = reader.readtext(path)
# 提取文字
for t in result:
print(t[1])
text_list.append(t[1])
return text_list
def save_text(text):
with open('识别结果.txt', 'w', encoding='utf-8') as file:
file.write('\n'.join(text))
file.flush()
if __name__ == '__main__':
path1 = '110.jpg'
text1 = get_text(path1)
save_text(text1)
1.识别的图片
2.识别结果