Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
不会修仙的道士
labelme
提交
7b49527c
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 搜索 >>
提交
7b49527c
编写于
10月 19, 2011
作者:
M
Michael Pitidis
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'feature/save-as'
上级
ba3bb270
e08e86ea
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
11 deletion
+32
-11
labelme.py
labelme.py
+32
-11
未找到文件。
labelme.py
浏览文件 @
7b49527c
...
...
@@ -31,6 +31,7 @@ __appname__ = 'labelme'
# alternate files. Either keep enabled, or add "Save As" button.
# TODO:
# - [high] Automatically add file suffix when saving.
# - [high] Deselect shape when clicking and already selected(?)
# - [high] Sanitize shortcuts between beginner/advanced mode.
# - [high] Figure out WhatsThis for help.
...
...
@@ -137,6 +138,9 @@ class MainWindow(QMainWindow, WindowMixin):
'Ctrl+O'
,
'open'
,
u
'Open image or label file'
)
save
=
action
(
'&Save'
,
self
.
saveFile
,
'Ctrl+S'
,
'save'
,
u
'Save labels to file'
,
enabled
=
False
)
saveAs
=
action
(
'&Save As'
,
self
.
saveFileAs
,
'Ctrl+Shift+S'
,
'save'
,
u
'Save labels to a different file'
,
enabled
=
False
)
close
=
action
(
'&Close'
,
self
.
closeFile
,
'Ctrl+K'
,
'close'
,
u
'Close current file'
)
color1
=
action
(
'Polygon &Line Color'
,
self
.
chooseColor1
,
...
...
@@ -221,7 +225,7 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
labelList
.
customContextMenuRequested
.
connect
(
self
.
popLabelListMenu
)
# Store actions for further handling.
self
.
actions
=
struct
(
save
=
save
,
open
=
open
,
close
=
close
,
self
.
actions
=
struct
(
save
=
save
,
saveAs
=
saveAs
,
open
=
open
,
close
=
close
,
lineColor
=
color1
,
fillColor
=
color2
,
create
=
create
,
delete
=
delete
,
edit
=
edit
,
copy
=
copy
,
createMode
=
createMode
,
editMode
=
editMode
,
advancedMode
=
advancedMode
,
...
...
@@ -229,14 +233,14 @@ class MainWindow(QMainWindow, WindowMixin):
zoom
=
zoom
,
zoomIn
=
zoomIn
,
zoomOut
=
zoomOut
,
zoomOrg
=
zoomOrg
,
fitWindow
=
fitWindow
,
fitWidth
=
fitWidth
,
zoomActions
=
zoomActions
,
fileMenuActions
=
(
open
,
save
,
close
,
quit
),
fileMenuActions
=
(
open
,
save
,
saveAs
,
close
,
quit
),
beginner
=
(),
advanced
=
(),
editMenu
=
(
edit
,
copy
,
delete
,
None
,
color1
,
color2
),
beginnerContext
=
(
create
,
edit
,
copy
,
delete
),
advancedContext
=
(
createMode
,
editMode
,
edit
,
copy
,
delete
,
shapeLineColor
,
shapeFillColor
),
onLoadActive
=
(
close
,
create
,
createMode
,
editMode
),
onShapesPresent
=
(
hideAll
,
showAll
))
onShapesPresent
=
(
saveAs
,
hideAll
,
showAll
))
self
.
menus
=
struct
(
file
=
self
.
menu
(
'&File'
),
...
...
@@ -722,15 +726,24 @@ class MainWindow(QMainWindow, WindowMixin):
def
saveFile
(
self
,
_value
=
False
):
assert
not
self
.
image
.
isNull
(),
"cannot save empty image"
assert
self
.
itemsToShapes
,
"cannot save empty labels"
formats
=
[
'*%s'
%
LabelFile
.
suffix
]
filename
=
unicode
(
QFileDialog
.
getSaveFileName
(
self
,
if
self
.
hasLabels
():
self
.
_saveFile
(
self
.
filename
if
self
.
labelFile
\
else
self
.
saveFileDialog
())
def
saveFileAs
(
self
,
_value
=
False
):
assert
not
self
.
image
.
isNull
(),
"cannot save empty image"
if
self
.
hasLabels
():
self
.
_saveFile
(
self
.
saveFileDialog
())
def
saveFileDialog
(
self
):
return
unicode
(
QFileDialog
.
getSaveFileName
(
self
,
'%s - Choose File'
,
self
.
currentPath
(),
'Label files (%s)'
%
''
.
join
(
formats
)))
if
filename
:
if
self
.
saveLabels
(
filename
):
self
.
addRecentFile
(
filename
)
self
.
setClean
()
'Label files (*%s)'
%
LabelFile
.
suffix
))
def
_saveFile
(
self
,
filename
):
if
filename
and
self
.
saveLabels
(
filename
):
self
.
addRecentFile
(
filename
)
self
.
setClean
()
def
closeFile
(
self
,
_value
=
False
):
if
not
self
.
mayContinue
():
...
...
@@ -739,8 +752,16 @@ class MainWindow(QMainWindow, WindowMixin):
self
.
setClean
()
self
.
toggleActions
(
False
)
self
.
canvas
.
setEnabled
(
False
)
self
.
actions
.
saveAs
.
setEnabled
(
False
)
# Message Dialogs. #
def
hasLabels
(
self
):
if
not
self
.
itemsToShapes
:
self
.
errorMessage
(
u
'No objects labeled'
,
u
'You must label at least one object to save the file.'
)
return
False
return
True
def
mayContinue
(
self
):
return
not
(
self
.
dirty
and
not
self
.
discardChangesDialog
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录