当前位置:网站首页>字符识别easyocr
字符识别easyocr
2022-04-23 05:30:00 【冰雪棋书】
#识别单张图片+显示+保存
#!-*-coding:utf-8-*-
import easyocr
import cv2
import time
reader=easyocr.Reader(['ch_sim','en'])
img=cv2.imread('test (1).jpg')
result=reader.readtext(img)
color=(0,0,255)
thick=3
for res in result:
print(res)
pos = res[0]
text = res[1]
for p in [(0,1),(1,2),(2,3),(3,0)]:
cv2.line(img,tuple(pos[p[0]]),tuple(pos[p[1]]),color,thick)
cv2.putText(img, text,(pos[0][0]+10,pos[0][1]-10), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255))
cv2.imshow('result',img)
time.sleep(10)
cv2.imwrite('bx-road-poetry.jpg',img)
#识别文件夹中的所有图片并保存
import easyocr
import cv2
import time
import os
reader=easyocr.Reader(['ch_sim','en'])
parent_path="./images/license_plate_test/"
for filename in os.listdir(parent_path):
print(filename)
path=os.path.join(parent_path,filename)
img=cv2.imread(path)
#img=cv2.imread('test (1).jpg')
result=reader.readtext(img)
color=(0,0,255)
thick=3
for res in result:
print(res)
pos = res[0]
text = res[1]
for p in [(0,1),(1,2),(2,3),(3,0)]:
cv2.line(img,tuple(pos[p[0]]),tuple(pos[p[1]]),color,thick)
cv2.putText(img, text,(pos[0][0]+10,pos[0][1]-10), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255))
#cv2.imshow('result',img)
#time.sleep(10)
cv2.imwrite("./reultimg/"+filename,img)
conda create easyocr
conda activate easyocr
pip install easyocr
pip install torch torchvision torchaudio
版本:
torch==1.5.1
torchvision==0.4.1
easyocr==1.4.2
注意版本问题,多次修改版本安装,以上版本可正常运行代码。
show的时候中文字符显示有问题,是OpenCV不支持中文字符的展示,需要对其转码。
版权声明
本文为[冰雪棋书]所创,转载请带上原文链接,感谢
https://blog.csdn.net/zml194849/article/details/124289673
边栏推荐
- Hongji cyclone RPA provides technical support for Guojin securities and realizes process automation in more than 200 business scenarios
- 弘玑微课堂 | Cyclone RPA之“灵活的数字员工”执行器
- C# ,类库
- 使用宝塔+xdebug+vscode远程调试代码
- 跨域CORS的情缘~
- Nécessité de précharger les cookies dans le sélénium
- QT displays the specified position and size of the picture
- The prefix of static of egg can be modified, including boots
- Three of three JS (webgl) is simple to draw lines / arcs according to points (based on linegeometry / line2 / linematerial, draw two arc segments based on the center of the circle)
- Vscode settings JSON configuration
猜你喜欢
Open source rule engine - Ice: dedicated to solving flexible and complex hard coding problems
Use of ES6 array
Traversal array, object parent-child communication props / $emit
QT displays the specified position and size of the picture
selenium預先加載cookie的必要性
Three of three JS (webgl) simple sorting of rotation attribute function, and a simple case of rotating around the axis based on this
Uniapp wechat sharing
[the background color changes after clicking a line]
CPT 104_TTL 09
!!!!!!!!!!!!!!!!!!
随机推荐
弘玑Cyclone RPA为国金证券提供技术支撑,超200个业务场景实现流程自动化
How to set the initial value of El input number to null
2021-09-27
Excel 2016 cannot open the file for the first time. Sometimes it is blank and sometimes it is very slow. You have to open it for the second time
After adding qmenu to qtoolbutton and QPushButton, remove the triangle icon in the lower right corner
TSlint注释忽略错误和RESTful理解
IPI interrupt
Uniapp wechat sharing
Various situations of data / component binding
Call the interface to get the time
(十一)vscode代码格式化配置
Usage and difference of shellexecute, shellexecuteex and winexec in QT
Utf8 to STD: string and STD: string to utf8
2021-09-28
Create process memory management copy_ Mm - processes and threads (IX)
Laravel implements the Holy Grail model with template inheritance
[triangle Yang Hui triangle printing odd even cycle JS for break cycle]
Processus d'exécution du programme exécutable
Uncle wolf is looking for a translator -- Plato -- ongoing translation
可執行程序執行流程