当前位置:网站首页>动手学ocr(一)
动手学ocr(一)
2022-08-02 14:02: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)
#下面这句话似乎可有可无的并不影响结构
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))
#代码此处做了修改
plt.imshow(image)
plt.show()
paddle
- 核心代码
声明PaddleOCR类:
ocr=PaddleOCR()
- 执行预测:
result =ocr.ocr(img_path,rec=False)
- 运行结果

- 其他库解释一下吧
- reshape改变数组形状
- 参数
(1)传入数组
(2)排序方式
一个形状尺寸可以是-1。在这种情况下,值是从数组的长度和剩余的维度推断出来的。
(3)order
‘C’ means C order, ‘F’ means Fortran order
order其实说实话看不太明白,等我看明白了一定补上
2)astype
强制转化数据类型
3)figure
figure(num=None, figsize=None, dpi=None, facecolor=None, edgecolor=None, frameon=True)
- 作用:我的理解是有点像是javafx的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())
#导入到路径中
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)
ppocr的路径和当前文件工作路径不同一开始没有找到,用了很多方法也没有用,使用了文章中第2种办法才能读取到文件
边栏推荐
- 文件加密软件有哪些?保障你的文件安全
- C language improvement (3)
- 网络剪枝(1)
- AWVS工具介绍[通俗易懂]
- Detailed explanation of ORACLE expdp/impdp
- CVE-2020-27986 (Sonarqube sensitive information leak) vulnerability fix
- 保姆级教程:写出自己的移动应用和小程序(篇三)
- 【Tensorflow】AttributeError: module ‘keras.backend‘ has no attribute ‘tf‘
- 关于C#使用DateTime数据的细节
- Mysql's case the when you how to use
猜你喜欢

How to solve 1045 cannot log in to mysql server

跑yolov5又出啥问题了(1)p,r,map全部为0

uview 2.x版本 tabbar在uniapp小程序里头点击两次才能选中图标

Flask项目的完整创建 七牛云与容联云

Raft协议图解,缺陷以及优化

The future of financial services will never stop, and the bull market will continue 2021-05-28

Differences and concepts between software testing and hardware testing

Configure zabbix auto-discovery and auto-registration.

不精确微分/不完全微分(Inexact differential/Imperfect differential)

网络安全第二次作业
随机推荐
Flask框架的搭建及入门
WiFi Association & Omnipeek Packet Capture Analysis
【Tensorflow】AttributeError: module 'keras.backend' has no attribute 'tf'
Object detection scene SSD-Mobilenetv1-FPN
第十五单元 分页、过滤
ORACLE expdp/impdp详解
MySQL数据库语法格式
FFmpeg 的AVCodecContext结构体详解
Sentinel源码(四)(滑动窗口流量统计)
第十四单元 视图集及路由
如何解决1045无法登录mysql服务器
【Tensorflow】AttributeError: ‘_TfDeviceCaptureOp‘ object has no attribute ‘_set_device_from_string‘
OpenMMLab简介
How to solve mysql service cannot start 1069
Break the limit of file locks and use storage power to help enterprises grow new momentum
你接受不了60%的暴跌,就没有资格获得6000%的涨幅 2021-05-27
世界上最大的开源基金会 Apache 是如何运作的?
网页设计(新手入门)[通俗易懂]
Some impressions of the 519 plummet 2021-05-21
文件加密软件有哪些?保障你的文件安全
