使用craft
2中安装方式:
git clone https://github.com/JaidedAI/EasyOCR.git
(base) xuehuiping@192 git % pip install EasyOCR & pip install -e .
或者:
pip install esayocr
测试图片:

测试代码:
- # -*- encoding: utf-8 -*-
- """
- @date: 2021/1/13 9:06 上午
- @author: xuehuiping
- """
- import easyocr
- reader = easyocr.Reader(['ch_sim','en']) # need to run only once to load model into memory
- result = reader.readtext('/Users/xuehuiping/Downloads/改进点/WX20201230-100641@2x@2x.png')
- print(result)
日志和输出:
- /Users/xuehuiping/anaconda3/bin/python /Users/xuehuiping/git/workspace/x10.py
- CUDA not available - defaulting to CPU. Note: This module is much faster with a GPU.
- Downloading detection model, please wait. This may take several minutes depending upon your network connection.
- Downloading recognition model, please wait. This may take several minutes depending upon your network connection.
-
- [([[168, 16], [232, 16], [232, 46], [168, 46]], '3个月', 0.9807953834533691),
- ([[298, 16], [362, 16], [362, 46], [298, 46]], '1个月', 0.9961197376251221),
- ([[32, 48], [112, 48], [112, 80], [32, 80]], '材料费', 0.9226560592651367),
- ([[180, 50], [224, 50], [224, 74], [180, 74]], '800', 0.5787679553031921),
- ([[310, 50], [354, 50], [354, 76], [310, 76]], '300', 0.9649673700332642),
- ([[46, 80], [100, 80], [100, 110], [46, 110]], '学费', 0.9960775971412659),
- ([[174, 82], [230, 82], [230, 108], [174, 108]], '9840', 0.8053710460662842),
- ([[304, 82], [360, 82], [360, 108], [304, 108]], '3280', 0.9644178152084351),
- ([[44, 112], [100, 112], [100, 142], [44, 142]], '餐费', 0.9910867810249329),
- ([[174, 114], [230, 114], [230, 140], [174, 140]], '1725', 0.8011188507080078),
- ([[310, 114], [354, 114], [354, 140], [310, 140]], '575', 0.6803759932518005)]
-
- Process finished with exit code 0
只输出识别结果:
detail=0
- result = reader.readtext('/Users/xuehuiping/Downloads/改进点/WX20201230-100641@2x.png', detail=0)
-
- ['3个月', '1个月', '材料费', '800', '300', '学费', '9840', '3280', '餐费', '1725', '575']
- 本机运行所用时间8s,gpu=False
模型文件保存目录:
- self.model_storage_directory = MODULE_PATH + '/model'
- ...
- MODULE_PATH = os.environ.get("EASYOCR_MODULE_PATH") or \
- os.environ.get("MODULE_PATH") or \
- os.path.expanduser("~/.EasyOCR/")
介绍:https://mp.weixin.qq.com/s/fq1UJcNP2RQ9yq1bFeXEZg
git:https://github.com/JaidedAI/EasyOCR
(xuehuiping) |