Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
6a42745f
Unverified
Commit
6a42745f
authored
Feb 22, 2021
by
Double_V
Committed by
GitHub
Feb 22, 2021
Browse files
Merge pull request #2060 from LDOUBLEV/fix2013
fix issue 2013
parents
816471aa
8f9dda86
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
7 deletions
+20
-7
ppocr/data/imaug/make_shrink_map.py
ppocr/data/imaug/make_shrink_map.py
+20
-7
No files found.
ppocr/data/imaug/make_shrink_map.py
View file @
6a42745f
...
...
@@ -44,21 +44,34 @@ class MakeShrinkMap(object):
ignore_tags
[
i
]
=
True
else
:
polygon_shape
=
Polygon
(
polygon
)
distance
=
polygon_shape
.
area
*
(
1
-
np
.
power
(
self
.
shrink_ratio
,
2
))
/
polygon_shape
.
length
subject
=
[
tuple
(
l
)
for
l
in
text_polys
[
i
]]
subject
=
[
tuple
(
l
)
for
l
in
polygon
]
padding
=
pyclipper
.
PyclipperOffset
()
padding
.
AddPath
(
subject
,
pyclipper
.
JT_ROUND
,
pyclipper
.
ET_CLOSEDPOLYGON
)
shrinked
=
[]
# Increase the shrink ratio every time we get multiple polygon returned back
possible_ratios
=
np
.
arange
(
self
.
shrink_ratio
,
1
,
self
.
shrink_ratio
)
np
.
append
(
possible_ratios
,
1
)
# print(possible_ratios)
for
ratio
in
possible_ratios
:
# print(f"Change shrink ratio to {ratio}")
distance
=
polygon_shape
.
area
*
(
1
-
np
.
power
(
ratio
,
2
))
/
polygon_shape
.
length
shrinked
=
padding
.
Execute
(
-
distance
)
if
len
(
shrinked
)
==
1
:
break
if
shrinked
==
[]:
cv2
.
fillPoly
(
mask
,
polygon
.
astype
(
np
.
int32
)[
np
.
newaxis
,
:,
:],
0
)
ignore_tags
[
i
]
=
True
continue
shrinked
=
np
.
array
(
shrinked
[
0
]).
reshape
(
-
1
,
2
)
cv2
.
fillPoly
(
gt
,
[
shrinked
.
astype
(
np
.
int32
)],
1
)
# cv2.fillPoly(gt[0], [shrinked.astype(np.int32)], 1)
for
each_shirnk
in
shrinked
:
shirnk
=
np
.
array
(
each_shirnk
).
reshape
(
-
1
,
2
)
cv2
.
fillPoly
(
gt
,
[
shirnk
.
astype
(
np
.
int32
)],
1
)
data
[
'shrink_map'
]
=
gt
data
[
'shrink_mask'
]
=
mask
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment