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
f025a135
Unverified
Commit
f025a135
authored
Jun 21, 2022
by
Double_V
Committed by
GitHub
Jun 21, 2022
Browse files
Merge pull request #6654 from LDOUBLEV/2.5
[bug fix] fix points order bug
parents
91bd75f4
2631755b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
tools/infer/predict_det.py
tools/infer/predict_det.py
+17
-8
No files found.
tools/infer/predict_det.py
View file @
f025a135
...
@@ -24,6 +24,7 @@ import cv2
...
@@ -24,6 +24,7 @@ import cv2
import
numpy
as
np
import
numpy
as
np
import
time
import
time
import
sys
import
sys
from
scipy.spatial
import
distance
as
dist
import
tools.infer.utility
as
utility
import
tools.infer.utility
as
utility
from
ppocr.utils.logging
import
get_logger
from
ppocr.utils.logging
import
get_logger
...
@@ -150,14 +151,22 @@ class TextDetector(object):
...
@@ -150,14 +151,22 @@ class TextDetector(object):
logger
=
logger
)
logger
=
logger
)
def
order_points_clockwise
(
self
,
pts
):
def
order_points_clockwise
(
self
,
pts
):
rect
=
np
.
zeros
((
4
,
2
),
dtype
=
"float32"
)
"""
s
=
pts
.
sum
(
axis
=
1
)
refer to :https://github.com/PyImageSearch/imutils/blob/9f740a53bcc2ed7eba2558afed8b4c17fd8a1d4c/imutils/perspective.py#L9
rect
[
0
]
=
pts
[
np
.
argmin
(
s
)]
"""
rect
[
2
]
=
pts
[
np
.
argmax
(
s
)]
# sort the points based on their x-coordinates
diff
=
np
.
diff
(
pts
,
axis
=
1
)
xSorted
=
pts
[
np
.
argsort
(
pts
[:,
0
]),
:]
rect
[
1
]
=
pts
[
np
.
argmin
(
diff
)]
rect
[
3
]
=
pts
[
np
.
argmax
(
diff
)]
leftMost
=
xSorted
[:
2
,
:]
return
rect
rightMost
=
xSorted
[
2
:,
:]
leftMost
=
leftMost
[
np
.
argsort
(
leftMost
[:,
1
]),
:]
(
tl
,
bl
)
=
leftMost
D
=
dist
.
cdist
(
tl
[
np
.
newaxis
],
rightMost
,
"euclidean"
)[
0
]
(
br
,
tr
)
=
rightMost
[
np
.
argsort
(
D
)[::
-
1
],
:]
return
np
.
array
([
tl
,
tr
,
br
,
bl
],
dtype
=
"float32"
)
def
clip_det_res
(
self
,
points
,
img_height
,
img_width
):
def
clip_det_res
(
self
,
points
,
img_height
,
img_width
):
for
pno
in
range
(
points
.
shape
[
0
]):
for
pno
in
range
(
points
.
shape
[
0
]):
...
...
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