Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
757d0160
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,发现更多精彩内容 >>
提交
757d0160
编写于
5月 11, 2021
作者:
W
WenmuZhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add det_use_polygon_score
上级
0f2d4027
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
52 addition
and
1 deletion
+52
-1
deploy/lite/config.txt
deploy/lite/config.txt
+1
-0
deploy/lite/db_post_process.cc
deploy/lite/db_post_process.cc
+51
-1
未找到文件。
deploy/lite/config.txt
浏览文件 @
757d0160
...
...
@@ -3,4 +3,5 @@ det_db_thresh 0.3
det_db_box_thresh 0.5
det_db_unclip_ratio 1.6
det_db_use_dilate 0
det_use_polygon_score 1
use_direction_classify 1
\ No newline at end of file
deploy/lite/db_post_process.cc
浏览文件 @
757d0160
...
...
@@ -190,6 +190,51 @@ float BoxScoreFast(std::vector<std::vector<float>> box_array, cv::Mat pred) {
return
score
;
}
float
PolygonScoreAcc
(
std
::
vector
<
cv
::
Point
>
contour
,
cv
::
Mat
pred
)
{
int
width
=
pred
.
cols
;
int
height
=
pred
.
rows
;
std
::
vector
<
float
>
box_x
;
std
::
vector
<
float
>
box_y
;
for
(
int
i
=
0
;
i
<
contour
.
size
();
++
i
)
{
box_x
.
push_back
(
contour
[
i
].
x
);
box_y
.
push_back
(
contour
[
i
].
y
);
}
int
xmin
=
clamp
(
int
(
std
::
floor
(
*
(
std
::
min_element
(
box_x
.
begin
(),
box_x
.
end
())))),
0
,
width
-
1
);
int
xmax
=
clamp
(
int
(
std
::
ceil
(
*
(
std
::
max_element
(
box_x
.
begin
(),
box_x
.
end
())))),
0
,
width
-
1
);
int
ymin
=
clamp
(
int
(
std
::
floor
(
*
(
std
::
min_element
(
box_y
.
begin
(),
box_y
.
end
())))),
0
,
height
-
1
);
int
ymax
=
clamp
(
int
(
std
::
ceil
(
*
(
std
::
max_element
(
box_y
.
begin
(),
box_y
.
end
())))),
0
,
height
-
1
);
cv
::
Mat
mask
;
mask
=
cv
::
Mat
::
zeros
(
ymax
-
ymin
+
1
,
xmax
-
xmin
+
1
,
CV_8UC1
);
cv
::
Point
*
rook_point
=
new
cv
::
Point
[
contour
.
size
()];
for
(
int
i
=
0
;
i
<
contour
.
size
();
++
i
)
{
rook_point
[
i
]
=
cv
::
Point
(
int
(
box_x
[
i
])
-
xmin
,
int
(
box_y
[
i
])
-
ymin
);
}
const
cv
::
Point
*
ppt
[
1
]
=
{
rook_point
};
int
npt
[]
=
{
int
(
contour
.
size
())};
cv
::
fillPoly
(
mask
,
ppt
,
npt
,
1
,
cv
::
Scalar
(
1
));
cv
::
Mat
croppedImg
;
pred
(
cv
::
Rect
(
xmin
,
ymin
,
xmax
-
xmin
+
1
,
ymax
-
ymin
+
1
))
.
copyTo
(
croppedImg
);
float
score
=
cv
::
mean
(
croppedImg
,
mask
)[
0
];
delete
[]
rook_point
;
return
score
;
}
std
::
vector
<
std
::
vector
<
std
::
vector
<
int
>>>
BoxesFromBitmap
(
const
cv
::
Mat
pred
,
const
cv
::
Mat
bitmap
,
std
::
map
<
std
::
string
,
double
>
Config
)
{
...
...
@@ -197,6 +242,7 @@ BoxesFromBitmap(const cv::Mat pred, const cv::Mat bitmap,
const
int
max_candidates
=
1000
;
const
float
box_thresh
=
static_cast
<
float
>
(
Config
[
"det_db_box_thresh"
]);
const
float
unclip_ratio
=
static_cast
<
float
>
(
Config
[
"det_db_unclip_ratio"
]);
const
int
det_use_polygon_score
=
int
(
Config
[
"det_use_polygon_score"
]);
int
width
=
bitmap
.
cols
;
int
height
=
bitmap
.
rows
;
...
...
@@ -228,7 +274,11 @@ BoxesFromBitmap(const cv::Mat pred, const cv::Mat bitmap,
}
float
score
;
score
=
BoxScoreFast
(
array
,
pred
);
if
(
det_use_polygon_score
)
{
score
=
PolygonScoreAcc
(
contours
[
i
],
pred
);
}
else
{
score
=
BoxScoreFast
(
array
,
pred
);
}
// end box_score_fast
if
(
score
<
box_thresh
)
continue
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录