- easyocr介绍easyocr是一款字符识别工具,支持80多种语言并且支持本地运行。支持语言为python,遵循 Apache-2.0协议,目前最新版本(2021年11月24日)为Version1.4.1。github地址为https://gitee.com/mirrors/EasyOCR。
- easyocr安装easyocr支持pip安装,打开cmd执行下列命令。
pip install easyocpip install git+git://github.com/jaidedai/easyocr.git
在window上安装时需要安装torch和torchvision并且选择正确的cuda版本,否则选择cuda=None。在进行代码运行时程序会自动下载相关模型。
3. easyocr使用
安装完成后进行测试,测试图像如下,之后键入下列代码
import easyocrreader = easyocr.Reader(['ch_sim','en']) # this needs to run only once to load the model into memoryresult = reader.readtext('E:/100.png')print(result)
从结果可以看到结果数据以列表形式展现,每个元素内分别有边界,文本和置信度组成。从代码中可以看出reader对象创建时指定了语言,这里可以同时指定多种语言,英语和多种语言均适配。在处理时除直接读取图像外,还支持opencv格式的图像传入,代码如下。
import easyocrimport cv2 as cvreader = easyocr.Reader(['ch_sim','en']) # this needs to run only once to load the model into memoryimage = cv.imread('E:/100.png')result = reader.readtext(image)print(result)
在模型选择方面,easyocr会默认选择最新模型,如果需要选择自己训练的或者其他模型可使用参数
reader = easyocr.Reader(['ch_sim','en'], recog_network='xxxx') # 官方模型地址为:# https://www.jaided.ai/easyocr/modelhub/
训练自己的模型参考以下链接:
https://github.com/JaidedAI/EasyOCR/blob/master/custom_model.md //链接https://github.com/clovaai/deep-text-recognition-benchmar //训练https://github.com/Belval/TextRecognitionDataGenerator // 数据集生成
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!