Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
27号BigBang
labelme
提交
cf2bd618
L
labelme
项目概览
27号BigBang
/
labelme
与 Fork 源项目一致
从无法访问的项目Fork
通知
6
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 搜索 >>
提交
cf2bd618
编写于
11月 06, 2018
作者:
S
Shohei Fujii
提交者:
Kentaro Wada
11月 06, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add linestrip
上级
9d5b2e7a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
42 addition
and
5 deletion
+42
-5
labelme/app.py
labelme/app.py
+26
-0
labelme/config/default_config.yaml
labelme/config/default_config.yaml
+1
-0
labelme/shape.py
labelme/shape.py
+6
-1
labelme/widgets/canvas.py
labelme/widgets/canvas.py
+9
-4
未找到文件。
labelme/app.py
浏览文件 @
cf2bd618
...
...
@@ -254,6 +254,14 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
'Start drawing points'
,
enabled
=
False
,
)
createLineStripMode
=
action
(
'Create LineStrip'
,
lambda
:
self
.
toggleDrawMode
(
False
,
createMode
=
'linestrip'
),
shortcuts
[
'create_linestrip'
],
'objects'
,
'Start drawing linestrip'
,
enabled
=
False
,
)
editMode
=
action
(
'Edit Polygons'
,
self
.
setEditMode
,
shortcuts
[
'edit_polygon'
],
'edit'
,
'Move and edit polygons'
,
enabled
=
False
)
...
...
@@ -364,6 +372,7 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
createCircleMode
=
createCircleMode
,
createLineMode
=
createLineMode
,
createPointMode
=
createPointMode
,
createLineStripMode
=
createLineStripMode
,
shapeLineColor
=
shapeLineColor
,
shapeFillColor
=
shapeFillColor
,
zoom
=
zoom
,
zoomIn
=
zoomIn
,
zoomOut
=
zoomOut
,
zoomOrg
=
zoomOrg
,
fitWindow
=
fitWindow
,
fitWidth
=
fitWidth
,
...
...
@@ -380,6 +389,7 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
createCircleMode
,
createLineMode
,
createPointMode
,
createLineStripMode
,
editMode
,
edit
,
copy
,
...
...
@@ -397,6 +407,7 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
createCircleMode
,
createLineMode
,
createPointMode
,
createLineStripMode
,
editMode
,
),
onShapesPresent
=
(
saveAs
,
hideAll
,
showAll
),
...
...
@@ -550,6 +561,7 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
self
.
actions
.
createCircleMode
,
self
.
actions
.
createLineMode
,
self
.
actions
.
createPointMode
,
self
.
actions
.
createLineStripMode
,
self
.
actions
.
editMode
,
)
addActions
(
self
.
menus
.
edit
,
actions
+
self
.
actions
.
editMenu
)
...
...
@@ -575,6 +587,7 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
self
.
actions
.
createCircleMode
.
setEnabled
(
True
)
self
.
actions
.
createLineMode
.
setEnabled
(
True
)
self
.
actions
.
createPointMode
.
setEnabled
(
True
)
self
.
actions
.
createLineStripMode
.
setEnabled
(
True
)
title
=
__appname__
if
self
.
filename
is
not
None
:
title
=
'{} - {}'
.
format
(
title
,
self
.
filename
)
...
...
@@ -649,6 +662,7 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
self
.
actions
.
createCircleMode
.
setEnabled
(
True
)
self
.
actions
.
createLineMode
.
setEnabled
(
True
)
self
.
actions
.
createPointMode
.
setEnabled
(
True
)
self
.
actions
.
createLineStripMode
.
setEnabled
(
True
)
else
:
if
createMode
==
'polygon'
:
self
.
actions
.
createMode
.
setEnabled
(
False
)
...
...
@@ -656,30 +670,42 @@ class MainWindow(QtWidgets.QMainWindow, WindowMixin):
self
.
actions
.
createCircleMode
.
setEnabled
(
True
)
self
.
actions
.
createLineMode
.
setEnabled
(
True
)
self
.
actions
.
createPointMode
.
setEnabled
(
True
)
self
.
actions
.
createLineStripMode
.
setEnabled
(
True
)
elif
createMode
==
'rectangle'
:
self
.
actions
.
createMode
.
setEnabled
(
True
)
self
.
actions
.
createRectangleMode
.
setEnabled
(
False
)
self
.
actions
.
createCircleMode
.
setEnabled
(
True
)
self
.
actions
.
createLineMode
.
setEnabled
(
True
)
self
.
actions
.
createPointMode
.
setEnabled
(
True
)
self
.
actions
.
createLineStripMode
.
setEnabled
(
True
)
elif
createMode
==
'line'
:
self
.
actions
.
createMode
.
setEnabled
(
True
)
self
.
actions
.
createRectangleMode
.
setEnabled
(
True
)
self
.
actions
.
createCircleMode
.
setEnabled
(
True
)
self
.
actions
.
createLineMode
.
setEnabled
(
False
)
self
.
actions
.
createPointMode
.
setEnabled
(
True
)
self
.
actions
.
createLineStripMode
.
setEnabled
(
True
)
elif
createMode
==
'point'
:
self
.
actions
.
createMode
.
setEnabled
(
True
)
self
.
actions
.
createRectangleMode
.
setEnabled
(
True
)
self
.
actions
.
createCircleMode
.
setEnabled
(
True
)
self
.
actions
.
createLineMode
.
setEnabled
(
True
)
self
.
actions
.
createPointMode
.
setEnabled
(
False
)
self
.
actions
.
createLineStripMode
.
setEnabled
(
True
)
elif
createMode
==
"circle"
:
self
.
actions
.
createMode
.
setEnabled
(
True
)
self
.
actions
.
createRectangleMode
.
setEnabled
(
True
)
self
.
actions
.
createCircleMode
.
setEnabled
(
False
)
self
.
actions
.
createLineMode
.
setEnabled
(
True
)
self
.
actions
.
createPointMode
.
setEnabled
(
True
)
self
.
actions
.
createLineStripMode
.
setEnabled
(
True
)
elif
createMode
==
"linestrip"
:
self
.
actions
.
createMode
.
setEnabled
(
True
)
self
.
actions
.
createRectangleMode
.
setEnabled
(
True
)
self
.
actions
.
createCircleMode
.
setEnabled
(
True
)
self
.
actions
.
createLineMode
.
setEnabled
(
True
)
self
.
actions
.
createPointMode
.
setEnabled
(
True
)
self
.
actions
.
createLineStripMode
.
setEnabled
(
False
)
else
:
raise
ValueError
(
'Unsupported createMode: %s'
%
createMode
)
self
.
actions
.
editMode
.
setEnabled
(
not
edit
)
...
...
labelme/config/default_config.yaml
浏览文件 @
cf2bd618
...
...
@@ -62,6 +62,7 @@ shortcuts:
create_circle
:
null
create_line
:
null
create_point
:
null
create_linestrip
:
null
edit_polygon
:
Ctrl+J
delete_polygon
:
Delete
duplicate_polygon
:
Ctrl+D
...
...
labelme/shape.py
浏览文件 @
cf2bd618
...
...
@@ -68,7 +68,7 @@ class Shape(object):
def
shape_type
(
self
,
value
):
if
value
is
None
:
value
=
'polygon'
if
value
not
in
[
'polygon'
,
'rectangle'
,
'point'
,
'line'
,
'circle'
]:
if
value
not
in
[
'polygon'
,
'rectangle'
,
'point'
,
'line'
,
'circle'
,
'linestrip'
]:
raise
ValueError
(
'Unexpected shape_type: {}'
.
format
(
value
))
self
.
_shape_type
=
value
...
...
@@ -126,6 +126,11 @@ class Shape(object):
line_path
.
addEllipse
(
rectangle
)
for
i
in
range
(
len
(
self
.
points
)):
self
.
drawVertex
(
vrtx_path
,
i
)
elif
self
.
shape_type
==
"linestrip"
:
line_path
.
moveTo
(
self
.
points
[
0
])
for
i
,
p
in
enumerate
(
self
.
points
):
line_path
.
lineTo
(
p
)
self
.
drawVertex
(
vrtx_path
,
i
)
else
:
line_path
.
moveTo
(
self
.
points
[
0
])
# Uncommenting the following line will draw 2 paths
...
...
labelme/widgets/canvas.py
浏览文件 @
cf2bd618
...
...
@@ -84,7 +84,7 @@ class Canvas(QtWidgets.QWidget):
@
createMode
.
setter
def
createMode
(
self
,
value
):
if
value
not
in
[
'polygon'
,
'rectangle'
,
'circle'
,
'line'
,
'point'
]:
if
value
not
in
[
'polygon'
,
'rectangle'
,
'circle'
,
'line'
,
'point'
,
'linestrip'
]:
raise
ValueError
(
'Unsupported createMode: %s'
%
value
)
self
.
_createMode
=
value
...
...
@@ -166,7 +166,7 @@ class Canvas(QtWidgets.QWidget):
# Don't allow the user to draw outside the pixmap.
# Project the point to the pixmap's edges.
pos
=
self
.
intersectionPoint
(
self
.
current
[
-
1
],
pos
)
elif
len
(
self
.
current
)
>
1
and
\
elif
len
(
self
.
current
)
>
1
and
self
.
createMode
==
'polygon'
and
\
self
.
closeEnough
(
pos
,
self
.
current
[
0
]):
# Attract line to starting point and
# colorise to alert the user.
...
...
@@ -174,7 +174,7 @@ class Canvas(QtWidgets.QWidget):
color
=
self
.
current
.
line_color
self
.
overrideCursor
(
CURSOR_POINT
)
self
.
current
.
highlightVertex
(
0
,
Shape
.
NEAR_VERTEX
)
if
self
.
createMode
==
'polygon'
:
if
self
.
createMode
in
[
'polygon'
,
'linestrip'
]
:
self
.
line
[
0
]
=
self
.
current
[
-
1
]
self
.
line
[
1
]
=
pos
elif
self
.
createMode
==
'rectangle'
:
...
...
@@ -292,6 +292,11 @@ class Canvas(QtWidgets.QWidget):
assert
len
(
self
.
current
.
points
)
==
1
self
.
current
.
points
=
self
.
line
.
points
self
.
finalise
()
elif
self
.
createMode
==
'linestrip'
:
self
.
current
.
addPoint
(
self
.
line
[
1
])
self
.
line
[
0
]
=
self
.
current
[
-
1
]
if
int
(
ev
.
modifiers
())
==
QtCore
.
Qt
.
ControlModifier
:
self
.
finalise
()
elif
not
self
.
outOfPixmap
(
pos
):
# Create new shape.
self
.
current
=
Shape
(
shape_type
=
self
.
createMode
)
...
...
@@ -644,7 +649,7 @@ class Canvas(QtWidgets.QWidget):
assert
self
.
shapes
self
.
current
=
self
.
shapes
.
pop
()
self
.
current
.
setOpen
()
if
self
.
createMode
==
'polygon'
:
if
self
.
createMode
in
[
'polygon'
,
'linestrip'
]
:
self
.
line
.
points
=
[
self
.
current
[
-
1
],
self
.
current
[
0
]]
elif
self
.
createMode
in
[
'rectangle'
,
'line'
,
'circle'
]:
self
.
current
.
points
=
self
.
current
.
points
[
0
:
1
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录