当前位置:网站首页>Hands-on OCR (1)
Hands-on OCR (1)
2022-08-02 14:18:00 【weixin_50862344】
文本检测:DBNet
环境:paddle
import matplotlib
from Cython import inline
from paddleocr import PaddleOCR
ocr=PaddleOCR()
#修改图片路径
img_path='D:/computervision/ocr/ppocr_img/imgs/12.jpg'
result =ocr.ocr(img_path,rec=False)
print(f'the predict as follow')
print(result)
import numpy as np
import cv2
import matplotlib.pyplot as plt
image = cv2.imread(img_path)
#The following sentence seems optional and does not affect the structure
boxes=[line[0] for line in result]
for box in result:
box=np.reshape(np.array(box),[-1,1,2]).astype(np.int64)
image=cv2.polylines(np.array(image),[box],True,(255,0,0),2)
plt.figure(figsize=(10,10))
#The code has been modified here
plt.imshow(image)
plt.show()
paddle
- 核心代码
声明PaddleOCR类:
ocr=PaddleOCR()
- 执行预测:
result =ocr.ocr(img_path,rec=False)
- 运行结果

- Please explain other libraries
- reshape改变数组形状
- 参数
(1)传入数组
(2)排序方式
A shape dimension can be-1.在这种情况下,The value is inferred from the length and remaining dimensions of the array.
Example from withcsdnanother blogger
(3)order
‘C’ means C order, ‘F’ means Fortran order
orderIn fact, I don't really understand it to be honest,I'll add it when I figure it out
2)astype
强制转化数据类型
3)figure
figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True)
- 作用:My understanding is kind of likejavafx的scence.
- 参数
num:图像编号或名称,数字为编号 ,字符串为名称
figsize:指定figure的宽和高,单位为英寸;
dpi参数:指定绘图对象的分辨率,即每英寸多少个像素,缺省值为80
facecolor:背景颜色
edgecolor:边框颜色
frameon:是否显示边框
DB文本检测模型
import paddle
import os
import sys
import importlib
# paddleocr_path='D:/computervision/ocr/PaddleOCR-release-2.5/PaddleOCR-release-2.5/ppocr'
# sys.path.append( paddleocr_path )
# os.chdir(paddleocr_path)
# print("当前工作目录"+os.getcwd())
#import into the path
from ppocr.modeling.backbones.det_mobilenet_v3 import MobileNetV3
fake_input=paddle.randn([1,3,640,640],dtype='float32')
model_backbone=MobileNetV3()
model_backbone.eval()
outs=model_backbone(fake_input)
print(model_backbone)
for idx,out in enumerate(outs):
print("the index",idx,"shape:",out.shape)
ppocrThe path is different from the current file working path and was not found at first,I tried many methods to no avail,used in the article第2种办法to read the file
边栏推荐
猜你喜欢

How does Apache, the world's largest open source foundation, work?

Interview | with questions to learn, Apache DolphinScheduler Wang Fuzheng
ROS通信 —— 话题(Topic)通信](/img/21/d79f2c4e246eb9ea39df9c7435bb36.png)
[ROS](06)ROS通信 —— 话题(Topic)通信

Gstreamer Plugin注册流程详解

Some impressions of the 519 plummet 2021-05-21

About the development forecast of the market outlook?2021-05-23

第十一单元 序列化器

How to solve 1045 cannot log in to mysql server

window10下半自动标注

理解TCP长连接(Keepalive)
随机推荐
window10下半自动标注
ftp常用命令详解_iftop命令详解
第十二单元 关联序列化处理
shell脚本“画画”
The most complete ever!A collection of 47 common terms of "digital transformation", read it in seconds~
paddle window10环境下使用conda安装
第六单元 初识ORM
第八单元 中间件
[ROS]ROS常用工具介绍(待续)
第五单元 保持状态
第十单元 前后连调
【Tensorflow】AttributeError: module 'keras.backend' has no attribute 'tf'
[ROS] (01) Create ROS workspace
瑞吉外卖笔记——第05讲Redis入门
第三单元 视图层
paddleocr window10初体验
ZABBIX配置邮件报警和微信报警
[ROS]roscd和cd的区别
跑跑yolov5吧
Unit 7 ORM table relationships and operations