当前位置:网站首页>字符识别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
边栏推荐
- MySQL series - install MySQL 5.6.27 on Linux and solve common problems
- d.ts---更详细的知识还是需要看官网的介绍(声明文件章节)
- catkin_package到底干了什么
- Self incrementing sequence creation of MySQL
- 狼叔来找翻译人员了--plato--持续翻译中.....
- what is wifi6?
- [the background color changes after clicking a line]
- 创建进程内存管理copy_mm - 进程与线程(九)
- [untitled] Notepad content writing area
- Arithmetic and logical operations
猜你喜欢
随机推荐
deep learning object detection
QSS, qdateedit, qcalendarwidget custom settings
Laravel implements the Holy Grail model with template inheritance
Qwebsocket communication
The QT debug version runs normally and the release version runs crash
The address value indicated by the pointer and the value of the object indicated by the pointer (learning notes)
Use of qwbengneview and qwebchannel.
Click the Add button - a box appears (similar to adding learning experience - undergraduate - Graduate)
uni使用的一些坑
五一劳动节期间什么理财产品会有收益?
Traversal array, object parent-child communication props / $emit
Redis in node -- ioredis
QSslSocket::connectToHostEncrypted: TLS initialization failed
Three of three JS (WEB GL) model deletion / scene emptying / simple sorting of memory release
Cmake basic tutorial (39) pkgconfig
Hongji | how does HR carry out self change and organizational change in the digital era?
Tslint annotations ignore errors and restful understanding
Xiuxian real world and game world
Parameter analysis of open3d material setting
2021-10-08







![Laravel [view]](/img/39/71db98d8832d9419bcc1097594d1b6.png)

