Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不会修仙的道士
labelme
提交
642d93e7
L
labelme
项目概览
不会修仙的道士
/
labelme
与 Fork 源项目一致
从无法访问的项目Fork
通知
4
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
labelme
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
642d93e7
编写于
7月 14, 2018
作者:
K
Kentaro Wada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add create point mode
上级
2e039e8d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
11 deletion
+50
-11
labelme/app.py
labelme/app.py
+34
-5
labelme/canvas.py
labelme/canvas.py
+15
-6
labelme/config/default_config.yaml
labelme/config/default_config.yaml
+1
-0
未找到文件。
labelme/app.py
浏览文件 @
642d93e7
...
...
@@ -285,6 +285,14 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
'Start drawing lines'
,
enabled
=
True
,
)
createPointMode
=
action
(
'Create Point'
,
lambda
:
self
.
toggleDrawMode
(
False
,
createMode
=
'point'
),
shortcuts
[
'create_point'
],
'objects'
,
'Start drawing points'
,
enabled
=
True
,
)
editMode
=
action
(
'Edit Polygons'
,
self
.
setEditMode
,
shortcuts
[
'edit_polygon'
],
'edit'
,
'Move and edit polygons'
,
enabled
=
True
)
...
...
@@ -387,6 +395,7 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
createMode
=
createMode
,
editMode
=
editMode
,
createRectangleMode
=
createRectangleMode
,
createLineMode
=
createLineMode
,
createPointMode
=
createPointMode
,
shapeLineColor
=
shapeLineColor
,
shapeFillColor
=
shapeFillColor
,
zoom
=
zoom
,
zoomIn
=
zoomIn
,
zoomOut
=
zoomOut
,
zoomOrg
=
zoomOrg
,
fitWindow
=
fitWindow
,
fitWidth
=
fitWidth
,
...
...
@@ -397,16 +406,26 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
None
,
color1
,
color2
),
# menu shown at right click
menu
=
(
createMode
,
createRectangleMode
,
createLineMode
,
editMode
,
edit
,
copy
,
delete
,
shapeLineColor
,
shapeFillColor
,
undo
,
undoLastPoint
,
addPoint
,
createMode
,
createRectangleMode
,
createLineMode
,
createPointMode
,
editMode
,
edit
,
copy
,
delete
,
shapeLineColor
,
shapeFillColor
,
undo
,
undoLastPoint
,
addPoint
,
),
onLoadActive
=
(
close
,
createMode
,
createRectangleMode
,
createLineMode
,
createPointMode
,
editMode
,
),
onShapesPresent
=
(
saveAs
,
hideAll
,
showAll
),
...
...
@@ -540,6 +559,7 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
self
.
actions
.
createMode
,
self
.
actions
.
createRectangleMode
,
self
.
actions
.
createLineMode
,
self
.
actions
.
createPointMode
,
self
.
actions
.
editMode
,
)
addActions
(
self
.
menus
.
edit
,
actions
+
self
.
actions
.
editMenu
)
...
...
@@ -563,6 +583,7 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
self
.
actions
.
createMode
.
setEnabled
(
True
)
self
.
actions
.
createRectangleMode
.
setEnabled
(
True
)
self
.
actions
.
createLineMode
.
setEnabled
(
True
)
self
.
actions
.
createPointMode
.
setEnabled
(
True
)
title
=
__appname__
if
self
.
filename
is
not
None
:
title
=
'{} - {}'
.
format
(
title
,
self
.
filename
)
...
...
@@ -635,16 +656,24 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
self
.
actions
.
createMode
.
setEnabled
(
edit
)
self
.
actions
.
createRectangleMode
.
setEnabled
(
not
edit
)
self
.
actions
.
createLineMode
.
setEnabled
(
not
edit
)
self
.
actions
.
createPointMode
.
setEnabled
(
not
edit
)
elif
createMode
==
'rectangle'
:
self
.
actions
.
createMode
.
setEnabled
(
not
edit
)
self
.
actions
.
createRectangleMode
.
setEnabled
(
edit
)
self
.
actions
.
createLineMode
.
setEnabled
(
not
edit
)
self
.
actions
.
createPointMode
.
setEnabled
(
not
edit
)
elif
createMode
==
'line'
:
self
.
actions
.
createMode
.
setEnabled
(
not
edit
)
self
.
actions
.
createRectangleMode
.
setEnabled
(
not
edit
)
self
.
actions
.
createLineMode
.
setEnabled
(
edit
)
self
.
actions
.
createPointMode
.
setEnabled
(
not
edit
)
elif
createMode
==
'point'
:
self
.
actions
.
createMode
.
setEnabled
(
not
edit
)
self
.
actions
.
createRectangleMode
.
setEnabled
(
not
edit
)
self
.
actions
.
createLineMode
.
setEnabled
(
not
edit
)
self
.
actions
.
createPointMode
.
setEnabled
(
edit
)
else
:
raise
ValueError
raise
ValueError
(
'Unsupported createMode: %s'
%
createMode
)
self
.
actions
.
editMode
.
setEnabled
(
not
edit
)
def
setEditMode
(
self
):
...
...
labelme/canvas.py
浏览文件 @
642d93e7
...
...
@@ -30,7 +30,7 @@ class Canvas(QtWidgets.QWidget):
CREATE
,
EDIT
=
0
,
1
# polygon, rectangle,
or line
# polygon, rectangle,
line, or point
_createMode
=
'polygon'
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -48,6 +48,7 @@ class Canvas(QtWidgets.QWidget):
# - createMode == 'polygon': edge from last point to current
# - createMode == 'rectangle': diagonal line of the rectangle
# - createMode == 'line': the line
# - createMode == 'point': the point
self
.
line
=
Shape
(
line_color
=
self
.
lineColor
)
self
.
prevPoint
=
QtCore
.
QPoint
()
self
.
prevMovePoint
=
QtCore
.
QPoint
()
...
...
@@ -75,7 +76,7 @@ class Canvas(QtWidgets.QWidget):
@
createMode
.
setter
def
createMode
(
self
,
value
):
if
value
not
in
[
'polygon'
,
'rectangle'
,
'line'
]:
if
value
not
in
[
'polygon'
,
'rectangle'
,
'line'
,
'point'
]:
raise
ValueError
(
'Unsupported createMode: %s'
%
value
)
self
.
_createMode
=
value
...
...
@@ -174,6 +175,9 @@ class Canvas(QtWidgets.QWidget):
elif
self
.
createMode
==
'line'
:
self
.
line
.
points
=
[
self
.
current
[
0
],
pos
]
self
.
line
.
close
()
elif
self
.
createMode
==
'point'
:
self
.
line
.
points
=
[
self
.
current
[
0
]]
self
.
line
.
close
()
self
.
line
.
line_color
=
color
self
.
repaint
()
self
.
current
.
highlightClear
()
...
...
@@ -288,10 +292,13 @@ class Canvas(QtWidgets.QWidget):
# Create new shape.
self
.
current
=
Shape
()
self
.
current
.
addPoint
(
pos
)
self
.
line
.
points
=
[
pos
,
pos
]
self
.
setHiding
()
self
.
drawingPolygon
.
emit
(
True
)
self
.
update
()
if
self
.
createMode
==
'point'
:
self
.
finalise
()
else
:
self
.
line
.
points
=
[
pos
,
pos
]
self
.
setHiding
()
self
.
drawingPolygon
.
emit
(
True
)
self
.
update
()
else
:
self
.
selectShapePoint
(
pos
)
self
.
prevPoint
=
pos
...
...
@@ -627,6 +634,8 @@ class Canvas(QtWidgets.QWidget):
self
.
line
.
points
=
[
self
.
current
[
-
1
],
self
.
current
[
0
]]
elif
self
.
createMode
in
[
'rectangle'
,
'line'
]:
self
.
current
.
points
=
self
.
current
.
points
[
0
:
1
]
elif
self
.
createMode
==
'point'
:
self
.
current
=
None
self
.
drawingPolygon
.
emit
(
True
)
def
undoLastPoint
(
self
):
...
...
labelme/config/default_config.yaml
浏览文件 @
642d93e7
...
...
@@ -31,6 +31,7 @@ shortcuts:
create_polygon
:
Ctrl+N
create_rectangle
:
Ctrl+R
create_line
:
null
create_point
:
null
edit_polygon
:
Ctrl+J
delete_polygon
:
Delete
duplicate_polygon
:
Ctrl+D
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录