Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
95ac9c0e
P
PaddleOCR
项目概览
PaddlePaddle
/
PaddleOCR
大约 1 年 前同步成功
通知
1528
Star
32962
Fork
6643
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
108
列表
看板
标记
里程碑
合并请求
7
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
108
Issue
108
列表
看板
标记
里程碑
合并请求
7
合并请求
7
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
95ac9c0e
编写于
4月 23, 2022
作者:
Z
zhoujun
提交者:
GitHub
4月 23, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6044 from WenmuZhou/cpp_infer1
rename PaddleOCR to PPOCR
上级
d7b107d1
8abef5a1
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
36 addition
and
24 deletion
+36
-24
deploy/cpp_infer/include/paddleocr.h
deploy/cpp_infer/include/paddleocr.h
+3
-3
deploy/cpp_infer/include/utility.h
deploy/cpp_infer/include/utility.h
+2
-0
deploy/cpp_infer/src/main.cpp
deploy/cpp_infer/src/main.cpp
+1
-1
deploy/cpp_infer/src/paddleocr.cpp
deploy/cpp_infer/src/paddleocr.cpp
+15
-18
deploy/cpp_infer/src/utility.cpp
deploy/cpp_infer/src/utility.cpp
+15
-2
未找到文件。
deploy/cpp_infer/include/paddleocr.h
浏览文件 @
95ac9c0e
...
...
@@ -39,10 +39,10 @@ using namespace paddle_infer;
namespace
PaddleOCR
{
class
P
addle
OCR
{
class
P
P
OCR
{
public:
explicit
P
addle
OCR
();
~
P
addle
OCR
();
explicit
P
P
OCR
();
~
P
P
OCR
();
std
::
vector
<
std
::
vector
<
OCRPredictResult
>>
ocr
(
std
::
vector
<
cv
::
String
>
cv_all_img_names
,
bool
det
=
true
,
bool
rec
=
true
,
bool
cls
=
true
);
...
...
deploy/cpp_infer/include/utility.h
浏览文件 @
95ac9c0e
...
...
@@ -65,6 +65,8 @@ public:
static
bool
PathExists
(
const
std
::
string
&
path
);
static
void
CreateDir
(
const
std
::
string
&
path
);
static
void
print_result
(
const
std
::
vector
<
OCRPredictResult
>
&
ocr_result
);
};
...
...
deploy/cpp_infer/src/main.cpp
浏览文件 @
95ac9c0e
...
...
@@ -69,7 +69,7 @@ int main(int argc, char **argv) {
cv
::
glob
(
FLAGS_image_dir
,
cv_all_img_names
);
std
::
cout
<<
"total images num: "
<<
cv_all_img_names
.
size
()
<<
endl
;
P
addleOCR
::
PaddleOCR
ocr
=
PaddleOCR
::
Paddle
OCR
();
P
POCR
ocr
=
PP
OCR
();
std
::
vector
<
std
::
vector
<
OCRPredictResult
>>
ocr_results
=
ocr
.
ocr
(
cv_all_img_names
,
FLAGS_det
,
FLAGS_rec
,
FLAGS_cls
);
...
...
deploy/cpp_infer/src/paddleocr.cpp
浏览文件 @
95ac9c0e
...
...
@@ -17,11 +17,9 @@
#include "auto_log/autolog.h"
#include <numeric>
#include <sys/stat.h>
namespace
PaddleOCR
{
P
addleOCR
::
Paddle
OCR
()
{
P
POCR
::
PP
OCR
()
{
if
(
FLAGS_det
)
{
this
->
detector_
=
new
DBDetector
(
FLAGS_det_model_dir
,
FLAGS_use_gpu
,
FLAGS_gpu_id
,
FLAGS_gpu_mem
,
...
...
@@ -45,8 +43,8 @@ PaddleOCR::PaddleOCR() {
}
};
void
P
addle
OCR
::
det
(
cv
::
Mat
img
,
std
::
vector
<
OCRPredictResult
>
&
ocr_results
,
std
::
vector
<
double
>
&
times
)
{
void
P
P
OCR
::
det
(
cv
::
Mat
img
,
std
::
vector
<
OCRPredictResult
>
&
ocr_results
,
std
::
vector
<
double
>
&
times
)
{
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>>>
boxes
;
std
::
vector
<
double
>
det_times
;
...
...
@@ -63,9 +61,9 @@ void PaddleOCR::det(cv::Mat img, std::vector<OCRPredictResult> &ocr_results,
times
[
2
]
+=
det_times
[
2
];
}
void
P
addle
OCR
::
rec
(
std
::
vector
<
cv
::
Mat
>
img_list
,
std
::
vector
<
OCRPredictResult
>
&
ocr_results
,
std
::
vector
<
double
>
&
times
)
{
void
P
P
OCR
::
rec
(
std
::
vector
<
cv
::
Mat
>
img_list
,
std
::
vector
<
OCRPredictResult
>
&
ocr_results
,
std
::
vector
<
double
>
&
times
)
{
std
::
vector
<
std
::
string
>
rec_texts
(
img_list
.
size
(),
""
);
std
::
vector
<
float
>
rec_text_scores
(
img_list
.
size
(),
0
);
std
::
vector
<
double
>
rec_times
;
...
...
@@ -80,9 +78,9 @@ void PaddleOCR::rec(std::vector<cv::Mat> img_list,
times
[
2
]
+=
rec_times
[
2
];
}
void
P
addle
OCR
::
cls
(
std
::
vector
<
cv
::
Mat
>
img_list
,
std
::
vector
<
OCRPredictResult
>
&
ocr_results
,
std
::
vector
<
double
>
&
times
)
{
void
P
P
OCR
::
cls
(
std
::
vector
<
cv
::
Mat
>
img_list
,
std
::
vector
<
OCRPredictResult
>
&
ocr_results
,
std
::
vector
<
double
>
&
times
)
{
std
::
vector
<
int
>
cls_labels
(
img_list
.
size
(),
0
);
std
::
vector
<
float
>
cls_scores
(
img_list
.
size
(),
0
);
std
::
vector
<
double
>
cls_times
;
...
...
@@ -98,8 +96,8 @@ void PaddleOCR::cls(std::vector<cv::Mat> img_list,
}
std
::
vector
<
std
::
vector
<
OCRPredictResult
>>
P
addle
OCR
::
ocr
(
std
::
vector
<
cv
::
String
>
cv_all_img_names
,
bool
det
,
bool
rec
,
bool
cls
)
{
P
P
OCR
::
ocr
(
std
::
vector
<
cv
::
String
>
cv_all_img_names
,
bool
det
,
bool
rec
,
bool
cls
)
{
std
::
vector
<
double
>
time_info_det
=
{
0
,
0
,
0
};
std
::
vector
<
double
>
time_info_rec
=
{
0
,
0
,
0
};
std
::
vector
<
double
>
time_info_cls
=
{
0
,
0
,
0
};
...
...
@@ -139,7 +137,7 @@ PaddleOCR::ocr(std::vector<cv::String> cv_all_img_names, bool det, bool rec,
}
}
else
{
if
(
!
Utility
::
PathExists
(
FLAGS_output
)
&&
FLAGS_det
)
{
mkdir
(
FLAGS_output
.
c_str
(),
0777
);
Utility
::
CreateDir
(
FLAGS_output
);
}
for
(
int
i
=
0
;
i
<
cv_all_img_names
.
size
();
++
i
)
{
...
...
@@ -188,9 +186,8 @@ PaddleOCR::ocr(std::vector<cv::String> cv_all_img_names, bool det, bool rec,
return
ocr_results
;
}
// namespace PaddleOCR
void
PaddleOCR
::
log
(
std
::
vector
<
double
>
&
det_times
,
std
::
vector
<
double
>
&
rec_times
,
std
::
vector
<
double
>
&
cls_times
,
int
img_num
)
{
void
PPOCR
::
log
(
std
::
vector
<
double
>
&
det_times
,
std
::
vector
<
double
>
&
rec_times
,
std
::
vector
<
double
>
&
cls_times
,
int
img_num
)
{
if
(
det_times
[
0
]
+
det_times
[
1
]
+
det_times
[
2
]
>
0
)
{
AutoLogger
autolog_det
(
"ocr_det"
,
FLAGS_use_gpu
,
FLAGS_use_tensorrt
,
FLAGS_enable_mkldnn
,
FLAGS_cpu_threads
,
1
,
"dynamic"
,
...
...
@@ -212,7 +209,7 @@ void PaddleOCR::log(std::vector<double> &det_times,
autolog_cls
.
report
();
}
}
P
addleOCR
::~
Paddle
OCR
()
{
P
POCR
::~
PP
OCR
()
{
if
(
this
->
detector_
!=
nullptr
)
{
delete
this
->
detector_
;
}
...
...
deploy/cpp_infer/src/utility.cpp
浏览文件 @
95ac9c0e
...
...
@@ -16,10 +16,15 @@
#include <include/utility.h>
#include <iostream>
#include <ostream>
#include <sys/stat.h>
#include <sys/types.h>
#include <vector>
#ifdef _WIN32
#include <direct.h>
#else
#include <sys/stat.h>
#endif
namespace
PaddleOCR
{
std
::
vector
<
std
::
string
>
Utility
::
ReadDict
(
const
std
::
string
&
path
)
{
...
...
@@ -206,6 +211,14 @@ bool Utility::PathExists(const std::string &path) {
#endif // !_WIN32
}
void
Utility
::
CreateDir
(
const
std
::
string
&
path
)
{
#ifdef _WIN32
_mkdir
(
path
.
c_str
());
#else
mkdir
(
path
.
c_str
(),
0777
);
#endif // !_WIN32
}
void
Utility
::
print_result
(
const
std
::
vector
<
OCRPredictResult
>
&
ocr_result
)
{
for
(
int
i
=
0
;
i
<
ocr_result
.
size
();
i
++
)
{
std
::
cout
<<
i
<<
"
\t
"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录