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
80edb0d6
Unverified
Commit
80edb0d6
authored
Mar 22, 2022
by
Evezerest
Committed by
GitHub
Mar 22, 2022
Browse files
Merge pull request #5729 from Evezerest/dygraph
Support multipoint labeling
parents
6a885632
fbb68c38
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
5 deletions
+48
-5
PPOCRLabel/PPOCRLabel.py
PPOCRLabel/PPOCRLabel.py
+39
-1
PPOCRLabel/README.md
PPOCRLabel/README.md
+1
-1
PPOCRLabel/README_ch.md
PPOCRLabel/README_ch.md
+2
-1
PPOCRLabel/libs/canvas.py
PPOCRLabel/libs/canvas.py
+1
-1
PPOCRLabel/libs/shape.py
PPOCRLabel/libs/shape.py
+5
-1
No files found.
PPOCRLabel/PPOCRLabel.py
View file @
80edb0d6
...
@@ -382,7 +382,7 @@ class MainWindow(QMainWindow):
...
@@ -382,7 +382,7 @@ class MainWindow(QMainWindow):
'w'
,
'objects'
,
getStr
(
'crtBoxDetail'
),
enabled
=
False
)
'w'
,
'objects'
,
getStr
(
'crtBoxDetail'
),
enabled
=
False
)
delete
=
action
(
getStr
(
'delBox'
),
self
.
deleteSelectedShape
,
delete
=
action
(
getStr
(
'delBox'
),
self
.
deleteSelectedShape
,
'
Alt+X
'
,
'delete'
,
getStr
(
'delBoxDetail'
),
enabled
=
False
)
'
backspace
'
,
'delete'
,
getStr
(
'delBoxDetail'
),
enabled
=
False
)
copy
=
action
(
getStr
(
'dupBox'
),
self
.
copySelectedShape
,
copy
=
action
(
getStr
(
'dupBox'
),
self
.
copySelectedShape
,
'Ctrl+C'
,
'copy'
,
getStr
(
'dupBoxDetail'
),
'Ctrl+C'
,
'copy'
,
getStr
(
'dupBoxDetail'
),
...
@@ -1939,6 +1939,38 @@ class MainWindow(QMainWindow):
...
@@ -1939,6 +1939,38 @@ class MainWindow(QMainWindow):
owidth
+=
itemwidget
.
width
()
owidth
+=
itemwidget
.
width
()
self
.
iconlist
.
setMinimumWidth
(
owidth
+
50
)
self
.
iconlist
.
setMinimumWidth
(
owidth
+
50
)
def
gen_quad_from_poly
(
self
,
poly
):
"""
Generate min area quad from poly.
"""
point_num
=
poly
.
shape
[
0
]
min_area_quad
=
np
.
zeros
((
4
,
2
),
dtype
=
np
.
float32
)
rect
=
cv2
.
minAreaRect
(
poly
.
astype
(
np
.
int32
))
# (center (x,y), (width, height), angle of rotation)
box
=
np
.
array
(
cv2
.
boxPoints
(
rect
))
first_point_idx
=
0
min_dist
=
1e4
for
i
in
range
(
4
):
dist
=
np
.
linalg
.
norm
(
box
[(
i
+
0
)
%
4
]
-
poly
[
0
])
+
\
np
.
linalg
.
norm
(
box
[(
i
+
1
)
%
4
]
-
poly
[
point_num
//
2
-
1
])
+
\
np
.
linalg
.
norm
(
box
[(
i
+
2
)
%
4
]
-
poly
[
point_num
//
2
])
+
\
np
.
linalg
.
norm
(
box
[(
i
+
3
)
%
4
]
-
poly
[
-
1
])
if
dist
<
min_dist
:
min_dist
=
dist
first_point_idx
=
i
for
i
in
range
(
4
):
min_area_quad
[
i
]
=
box
[(
first_point_idx
+
i
)
%
4
]
bbox_new
=
min_area_quad
.
tolist
()
bbox
=
[]
for
box
in
bbox_new
:
box
=
list
(
map
(
int
,
box
))
bbox
.
append
(
box
)
return
bbox
def
getImglabelidx
(
self
,
filePath
):
def
getImglabelidx
(
self
,
filePath
):
if
platform
.
system
()
==
'Windows'
:
if
platform
.
system
()
==
'Windows'
:
spliter
=
'
\\
'
spliter
=
'
\\
'
...
@@ -1973,7 +2005,11 @@ class MainWindow(QMainWindow):
...
@@ -1973,7 +2005,11 @@ class MainWindow(QMainWindow):
rec_flag
=
0
rec_flag
=
0
for
shape
in
self
.
canvas
.
shapes
:
for
shape
in
self
.
canvas
.
shapes
:
box
=
[[
int
(
p
.
x
()),
int
(
p
.
y
())]
for
p
in
shape
.
points
]
box
=
[[
int
(
p
.
x
()),
int
(
p
.
y
())]
for
p
in
shape
.
points
]
if
len
(
box
)
>
4
:
box
=
self
.
gen_quad_from_poly
(
np
.
array
(
box
))
assert
len
(
box
)
==
4
assert
len
(
box
)
==
4
img_crop
=
get_rotate_crop_image
(
img
,
np
.
array
(
box
,
np
.
float32
))
img_crop
=
get_rotate_crop_image
(
img
,
np
.
array
(
box
,
np
.
float32
))
if
img_crop
is
None
:
if
img_crop
is
None
:
msg
=
'Can not recognise the detection box in '
+
self
.
filePath
+
'. Please change manually'
msg
=
'Can not recognise the detection box in '
+
self
.
filePath
+
'. Please change manually'
...
@@ -2022,6 +2058,8 @@ class MainWindow(QMainWindow):
...
@@ -2022,6 +2058,8 @@ class MainWindow(QMainWindow):
img
=
cv2
.
imread
(
self
.
filePath
)
img
=
cv2
.
imread
(
self
.
filePath
)
for
shape
in
self
.
canvas
.
selectedShapes
:
for
shape
in
self
.
canvas
.
selectedShapes
:
box
=
[[
int
(
p
.
x
()),
int
(
p
.
y
())]
for
p
in
shape
.
points
]
box
=
[[
int
(
p
.
x
()),
int
(
p
.
y
())]
for
p
in
shape
.
points
]
if
len
(
box
)
>
4
:
box
=
self
.
gen_quad_from_poly
(
np
.
array
(
box
))
assert
len
(
box
)
==
4
assert
len
(
box
)
==
4
img_crop
=
get_rotate_crop_image
(
img
,
np
.
array
(
box
,
np
.
float32
))
img_crop
=
get_rotate_crop_image
(
img
,
np
.
array
(
box
,
np
.
float32
))
if
img_crop
is
None
:
if
img_crop
is
None
:
...
...
PPOCRLabel/README.md
View file @
80edb0d6
...
@@ -170,7 +170,7 @@ python PPOCRLabel.py --kie True # [KIE mode] for [detection + recognition + keyw
...
@@ -170,7 +170,7 @@ python PPOCRLabel.py --kie True # [KIE mode] for [detection + recognition + keyw
| Ctrl + R | Re-recognize the selected box |
| Ctrl + R | Re-recognize the selected box |
| Ctrl + C | Copy and paste the selected box |
| Ctrl + C | Copy and paste the selected box |
| Ctrl + Left Mouse Button | Multi select the label box |
| Ctrl + Left Mouse Button | Multi select the label box |
|
Alt + X
| Delete the selected box |
|
Backspace
| Delete the selected box |
| Ctrl + V | Check image |
| Ctrl + V | Check image |
| Ctrl + Shift + d | Delete image |
| Ctrl + Shift + d | Delete image |
| D | Next image |
| D | Next image |
...
...
PPOCRLabel/README_ch.md
View file @
80edb0d6
...
@@ -159,7 +159,7 @@ python PPOCRLabel.py --lang ch --kie True # 启动 【KIE 模式】,用于打
...
@@ -159,7 +159,7 @@ python PPOCRLabel.py --lang ch --kie True # 启动 【KIE 模式】,用于打
| Ctrl + R | 重新识别所选标记 |
| Ctrl + R | 重新识别所选标记 |
| Ctrl + C | 复制并粘贴选中的标记框 |
| Ctrl + C | 复制并粘贴选中的标记框 |
| Ctrl + 鼠标左键 | 多选标记框 |
| Ctrl + 鼠标左键 | 多选标记框 |
|
Alt + X
| 删除所选框 |
|
Backspace
| 删除所选框 |
| Ctrl + V | 确认本张图片标记 |
| Ctrl + V | 确认本张图片标记 |
| Ctrl + Shift + d | 删除本张图片 |
| Ctrl + Shift + d | 删除本张图片 |
| D | 下一张图片 |
| D | 下一张图片 |
...
@@ -168,6 +168,7 @@ python PPOCRLabel.py --lang ch --kie True # 启动 【KIE 模式】,用于打
...
@@ -168,6 +168,7 @@ python PPOCRLabel.py --lang ch --kie True # 启动 【KIE 模式】,用于打
| Ctrl-- | 放大 |
| Ctrl-- | 放大 |
| ↑→↓← | 移动标记框 |
| ↑→↓← | 移动标记框 |
### 3.2 内置模型
### 3.2 内置模型
-
默认模型:PPOCRLabel默认使用PaddleOCR中的中英文超轻量OCR模型,支持中英文与数字识别,多种语言检测。
-
默认模型:PPOCRLabel默认使用PaddleOCR中的中英文超轻量OCR模型,支持中英文与数字识别,多种语言检测。
...
...
PPOCRLabel/libs/canvas.py
View file @
80edb0d6
...
@@ -263,7 +263,7 @@ class Canvas(QWidget):
...
@@ -263,7 +263,7 @@ class Canvas(QWidget):
if
self
.
current
.
isClosed
():
if
self
.
current
.
isClosed
():
# print('1111')
# print('1111')
self
.
finalise
()
self
.
finalise
()
elif
self
.
drawSquare
:
# 增加
elif
self
.
drawSquare
:
assert
len
(
self
.
current
.
points
)
==
1
assert
len
(
self
.
current
.
points
)
==
1
self
.
current
.
points
=
self
.
line
.
points
self
.
current
.
points
=
self
.
line
.
points
self
.
finalise
()
self
.
finalise
()
...
...
PPOCRLabel/libs/shape.py
View file @
80edb0d6
...
@@ -57,6 +57,7 @@ class Shape(object):
...
@@ -57,6 +57,7 @@ class Shape(object):
self
.
locked
=
False
self
.
locked
=
False
self
.
direction
=
0
self
.
direction
=
0
self
.
center
=
None
self
.
center
=
None
self
.
epsilon
=
5
# same as canvas
self
.
_highlightIndex
=
None
self
.
_highlightIndex
=
None
self
.
_highlightMode
=
self
.
NEAR_VERTEX
self
.
_highlightMode
=
self
.
NEAR_VERTEX
self
.
_highlightSettings
=
{
self
.
_highlightSettings
=
{
...
@@ -98,11 +99,14 @@ class Shape(object):
...
@@ -98,11 +99,14 @@ class Shape(object):
return
False
return
False
def
addPoint
(
self
,
point
):
def
addPoint
(
self
,
point
):
if
self
.
reachMaxPoints
():
if
self
.
reachMaxPoints
()
and
self
.
closeEnough
(
self
.
points
[
0
],
point
)
:
self
.
close
()
self
.
close
()
else
:
else
:
self
.
points
.
append
(
point
)
self
.
points
.
append
(
point
)
def
closeEnough
(
self
,
p1
,
p2
):
return
distance
(
p1
-
p2
)
<
self
.
epsilon
def
popPoint
(
self
):
def
popPoint
(
self
):
if
self
.
points
:
if
self
.
points
:
return
self
.
points
.
pop
()
return
self
.
points
.
pop
()
...
...
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