Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_41840029
PaddleOCR
提交
3c6d5512
P
PaddleOCR
项目概览
weixin_41840029
/
PaddleOCR
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleOCR
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleOCR
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3c6d5512
编写于
3月 18, 2022
作者:
qq_25193841
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support multipoint labeling
Support multipoint labeling
上级
70ea536a
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
47 addition
and
5 deletion
+47
-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
+1
-1
PPOCRLabel/libs/canvas.py
PPOCRLabel/libs/canvas.py
+1
-1
PPOCRLabel/libs/shape.py
PPOCRLabel/libs/shape.py
+5
-1
未找到文件。
PPOCRLabel/PPOCRLabel.py
浏览文件 @
3c6d5512
...
...
@@ -379,7 +379,7 @@ class MainWindow(QMainWindow):
'w'
,
'objects'
,
getStr
(
'crtBoxDetail'
),
enabled
=
False
)
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
,
'Ctrl+C'
,
'copy'
,
getStr
(
'dupBoxDetail'
),
...
...
@@ -1931,6 +1931,38 @@ class MainWindow(QMainWindow):
owidth
+=
itemwidget
.
width
()
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
):
if
platform
.
system
()
==
'Windows'
:
spliter
=
'
\\
'
...
...
@@ -1965,7 +1997,11 @@ class MainWindow(QMainWindow):
rec_flag
=
0
for
shape
in
self
.
canvas
.
shapes
:
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
img_crop
=
get_rotate_crop_image
(
img
,
np
.
array
(
box
,
np
.
float32
))
if
img_crop
is
None
:
msg
=
'Can not recognise the detection box in '
+
self
.
filePath
+
'. Please change manually'
...
...
@@ -2014,6 +2050,8 @@ class MainWindow(QMainWindow):
img
=
cv2
.
imread
(
self
.
filePath
)
for
shape
in
self
.
canvas
.
selectedShapes
:
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
img_crop
=
get_rotate_crop_image
(
img
,
np
.
array
(
box
,
np
.
float32
))
if
img_crop
is
None
:
...
...
PPOCRLabel/README.md
浏览文件 @
3c6d5512
...
...
@@ -159,7 +159,7 @@ python PPOCRLabel.py --kie True # [KIE mode] for [detection + recognition + keyw
| Ctrl + R | Re-recognize the selected box |
| Ctrl + C | Copy and paste the selected 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 + Shift + d | Delete image |
| D | Next image |
...
...
PPOCRLabel/README_ch.md
浏览文件 @
3c6d5512
...
...
@@ -148,7 +148,7 @@ python PPOCRLabel.py --lang ch --kie True # 启动 【KIE 模式】,用于打
| Ctrl + R | 重新识别所选标记 |
| Ctrl + C | 复制并粘贴选中的标记框 |
| Ctrl + 鼠标左键 | 多选标记框 |
|
Alt + X
| 删除所选框 |
|
Backspace
| 删除所选框 |
| Ctrl + V | 确认本张图片标记 |
| Ctrl + Shift + d | 删除本张图片 |
| D | 下一张图片 |
...
...
PPOCRLabel/libs/canvas.py
浏览文件 @
3c6d5512
...
...
@@ -263,7 +263,7 @@ class Canvas(QWidget):
if
self
.
current
.
isClosed
():
# print('1111')
self
.
finalise
()
elif
self
.
drawSquare
:
# 增加
elif
self
.
drawSquare
:
assert
len
(
self
.
current
.
points
)
==
1
self
.
current
.
points
=
self
.
line
.
points
self
.
finalise
()
...
...
PPOCRLabel/libs/shape.py
浏览文件 @
3c6d5512
...
...
@@ -57,6 +57,7 @@ class Shape(object):
self
.
locked
=
False
self
.
direction
=
0
self
.
center
=
None
self
.
epsilon
=
5
# same as canvas
self
.
_highlightIndex
=
None
self
.
_highlightMode
=
self
.
NEAR_VERTEX
self
.
_highlightSettings
=
{
...
...
@@ -98,11 +99,14 @@ class Shape(object):
return
False
def
addPoint
(
self
,
point
):
if
self
.
reachMaxPoints
():
if
self
.
reachMaxPoints
()
and
self
.
closeEnough
(
self
.
points
[
0
],
point
)
:
self
.
close
()
else
:
self
.
points
.
append
(
point
)
def
closeEnough
(
self
,
p1
,
p2
):
return
distance
(
p1
-
p2
)
<
self
.
epsilon
def
popPoint
(
self
):
if
self
.
points
:
return
self
.
points
.
pop
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录