Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleOCR
提交
0bd5e159
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看板
提交
0bd5e159
编写于
2月 20, 2022
作者:
HinGwenWoong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Different key show different color
上级
4f8b1375
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
13 addition
and
16 deletion
+13
-16
PPOCRLabel/PPOCRLabel.py
PPOCRLabel/PPOCRLabel.py
+11
-10
PPOCRLabel/libs/unique_label_qlist_widget.py
PPOCRLabel/libs/unique_label_qlist_widget.py
+2
-6
未找到文件。
PPOCRLabel/PPOCRLabel.py
浏览文件 @
0bd5e159
...
@@ -366,7 +366,7 @@ class MainWindow(QMainWindow):
...
@@ -366,7 +366,7 @@ class MainWindow(QMainWindow):
resetAll
=
action
(
getStr
(
'resetAll'
),
self
.
resetAll
,
None
,
'resetall'
,
getStr
(
'resetAllDetail'
))
resetAll
=
action
(
getStr
(
'resetAll'
),
self
.
resetAll
,
None
,
'resetall'
,
getStr
(
'resetAllDetail'
))
color1
=
action
(
getStr
(
'boxLineColor'
),
self
.
chooseColor
1
,
color1
=
action
(
getStr
(
'boxLineColor'
),
self
.
chooseColor
,
'Ctrl+L'
,
'color_line'
,
getStr
(
'boxLineColorDetail'
))
'Ctrl+L'
,
'color_line'
,
getStr
(
'boxLineColorDetail'
))
createMode
=
action
(
getStr
(
'crtBox'
),
self
.
setCreateMode
,
createMode
=
action
(
getStr
(
'crtBox'
),
self
.
setCreateMode
,
...
@@ -1042,7 +1042,7 @@ class MainWindow(QMainWindow):
...
@@ -1042,7 +1042,7 @@ class MainWindow(QMainWindow):
def
loadLabels
(
self
,
shapes
):
def
loadLabels
(
self
,
shapes
):
s
=
[]
s
=
[]
for
label
,
points
,
line_color
,
key
,
difficult
in
shapes
:
for
label
,
points
,
line_color
,
key
_cls
,
difficult
in
shapes
:
shape
=
Shape
(
label
=
label
,
line_color
=
line_color
)
shape
=
Shape
(
label
=
label
,
line_color
=
line_color
)
for
x
,
y
in
points
:
for
x
,
y
in
points
:
...
@@ -1207,6 +1207,7 @@ class MainWindow(QMainWindow):
...
@@ -1207,6 +1207,7 @@ class MainWindow(QMainWindow):
if
text
is
not
None
:
if
text
is
not
None
:
self
.
prevLabelText
=
self
.
stringBundle
.
getString
(
'tempLabel'
)
self
.
prevLabelText
=
self
.
stringBundle
.
getString
(
'tempLabel'
)
shape
=
self
.
canvas
.
setLastLabel
(
text
,
None
,
None
,
None
)
# generate_color, generate_color
if
self
.
kie_mode
:
if
self
.
kie_mode
:
key_text
,
_
=
self
.
keyDialog
.
popUp
(
self
.
key_previous_text
)
key_text
,
_
=
self
.
keyDialog
.
popUp
(
self
.
key_previous_text
)
if
key_text
is
not
None
:
if
key_text
is
not
None
:
...
@@ -1217,9 +1218,9 @@ class MainWindow(QMainWindow):
...
@@ -1217,9 +1218,9 @@ class MainWindow(QMainWindow):
self
.
keyList
.
addItem
(
item
)
self
.
keyList
.
addItem
(
item
)
rgb
=
self
.
_get_rgb_by_label
(
key_text
,
self
.
kie_mode
)
rgb
=
self
.
_get_rgb_by_label
(
key_text
,
self
.
kie_mode
)
self
.
keyList
.
setItemLabel
(
item
,
key_text
,
rgb
)
self
.
keyList
.
setItemLabel
(
item
,
key_text
,
rgb
)
self
.
_update_shape_color
(
shape
)
self
.
keyDialog
.
addLabelHistory
(
key_text
)
self
.
keyDialog
.
addLabelHistory
(
key_text
)
else
:
shape
=
self
.
canvas
.
setLastLabel
(
text
,
None
,
None
,
None
)
# generate_color, generate_color
self
.
addLabel
(
shape
)
self
.
addLabel
(
shape
)
if
self
.
beginner
():
# Switch to edit mode.
if
self
.
beginner
():
# Switch to edit mode.
...
@@ -1236,7 +1237,7 @@ class MainWindow(QMainWindow):
...
@@ -1236,7 +1237,7 @@ class MainWindow(QMainWindow):
self
.
canvas
.
resetAllLines
()
self
.
canvas
.
resetAllLines
()
def
_update_shape_color
(
self
,
shape
):
def
_update_shape_color
(
self
,
shape
):
r
,
g
,
b
=
self
.
_get_rgb_by_label
(
shape
.
label
)
r
,
g
,
b
=
self
.
_get_rgb_by_label
(
shape
.
key_cls
,
self
.
kie_mode
)
shape
.
line_color
=
QtGui
.
QColor
(
r
,
g
,
b
)
shape
.
line_color
=
QtGui
.
QColor
(
r
,
g
,
b
)
shape
.
vertex_fill_color
=
QtGui
.
QColor
(
r
,
g
,
b
)
shape
.
vertex_fill_color
=
QtGui
.
QColor
(
r
,
g
,
b
)
shape
.
hvertex_fill_color
=
QtGui
.
QColor
(
255
,
255
,
255
)
shape
.
hvertex_fill_color
=
QtGui
.
QColor
(
255
,
255
,
255
)
...
@@ -1245,8 +1246,8 @@ class MainWindow(QMainWindow):
...
@@ -1245,8 +1246,8 @@ class MainWindow(QMainWindow):
shape
.
select_fill_color
=
QtGui
.
QColor
(
r
,
g
,
b
,
155
)
shape
.
select_fill_color
=
QtGui
.
QColor
(
r
,
g
,
b
,
155
)
def
_get_rgb_by_label
(
self
,
label
,
kie_mode
):
def
_get_rgb_by_label
(
self
,
label
,
kie_mode
):
shift_auto_shape_color
=
0
# use for random color
shift_auto_shape_color
=
2
# use for random color
if
kie_mode
:
if
kie_mode
and
label
!=
"None"
:
item
=
self
.
keyList
.
findItemsByLabel
(
label
)[
0
]
item
=
self
.
keyList
.
findItemsByLabel
(
label
)[
0
]
label_id
=
self
.
keyList
.
indexFromItem
(
item
).
row
()
+
1
label_id
=
self
.
keyList
.
indexFromItem
(
item
).
row
()
+
1
label_id
+=
shift_auto_shape_color
label_id
+=
shift_auto_shape_color
...
@@ -1816,7 +1817,7 @@ class MainWindow(QMainWindow):
...
@@ -1816,7 +1817,7 @@ class MainWindow(QMainWindow):
def
currentPath
(
self
):
def
currentPath
(
self
):
return
os
.
path
.
dirname
(
self
.
filePath
)
if
self
.
filePath
else
'.'
return
os
.
path
.
dirname
(
self
.
filePath
)
if
self
.
filePath
else
'.'
def
chooseColor
1
(
self
):
def
chooseColor
(
self
):
color
=
self
.
colorDialog
.
getColor
(
self
.
lineColor
,
u
'Choose line color'
,
color
=
self
.
colorDialog
.
getColor
(
self
.
lineColor
,
u
'Choose line color'
,
default
=
DEFAULT_LINE_COLOR
)
default
=
DEFAULT_LINE_COLOR
)
if
color
:
if
color
:
...
@@ -2206,8 +2207,8 @@ class MainWindow(QMainWindow):
...
@@ -2206,8 +2207,8 @@ class MainWindow(QMainWindow):
line_color
=
s
.
line_color
.
getRgb
(),
line_color
=
s
.
line_color
.
getRgb
(),
fill_color
=
s
.
fill_color
.
getRgb
(),
fill_color
=
s
.
fill_color
.
getRgb
(),
ratio
=
[[
int
(
p
.
x
())
/
width
,
int
(
p
.
y
())
/
height
]
for
p
in
s
.
points
],
# QPonitF
ratio
=
[[
int
(
p
.
x
())
/
width
,
int
(
p
.
y
())
/
height
]
for
p
in
s
.
points
],
# QPonitF
difficult
=
s
.
difficult
,
# bool
difficult
=
s
.
difficult
,
# bool
key_cls
=
s
.
key_cls
,
# bool
key_cls
=
s
.
key_cls
,
# bool
)
)
# lock
# lock
...
...
PPOCRLabel/libs/unique_label_qlist_widget.py
浏览文件 @
0bd5e159
...
@@ -33,13 +33,9 @@ class UniqueLabelQListWidget(EscapableQListWidget):
...
@@ -33,13 +33,9 @@ class UniqueLabelQListWidget(EscapableQListWidget):
def
setItemLabel
(
self
,
item
,
label
,
color
=
None
):
def
setItemLabel
(
self
,
item
,
label
,
color
=
None
):
qlabel
=
QtWidgets
.
QLabel
()
qlabel
=
QtWidgets
.
QLabel
()
if
color
is
None
:
if
color
is
None
:
qlabel
.
setText
(
"{}"
.
format
(
label
)
)
qlabel
.
setText
(
f
"
{
label
}
"
)
else
:
else
:
qlabel
.
setText
(
qlabel
.
setText
(
'<font color="#{:02x}{:02x}{:02x}">●</font> {} '
.
format
(
*
color
,
label
))
'{} <font color="#{:02x}{:02x}{:02x}">●</font>'
.
format
(
label
,
*
color
)
)
qlabel
.
setAlignment
(
Qt
.
AlignBottom
)
qlabel
.
setAlignment
(
Qt
.
AlignBottom
)
item
.
setSizeHint
(
qlabel
.
sizeHint
())
item
.
setSizeHint
(
qlabel
.
sizeHint
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录