Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sloth/bin/sloth
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from PyQt4.QtGui import QApplication
from sloth.core.labeltool import LabelTool
from sloth import APP_NAME, ORGANIZATION_NAME, ORGANIZATION_DOMAIN


if __name__ == '__main__':
app = QApplication(sys.argv)
app.setOrganizationName(ORGANIZATION_NAME)
Expand All @@ -15,5 +16,6 @@ if __name__ == '__main__':
labeltool = LabelTool()
labeltool.execute_from_commandline(sys.argv)

sys.exit(app.exec_())


sys.exit(app.exec_())
8 changes: 4 additions & 4 deletions sloth/core/labeltool.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,12 @@ def setCurrentImage(self, image):
self._current_image = image
self.currentImageChanged.emit()

def getImage(self, item):
def getImage(self, item, image = 'filename'):
if item['class'] == 'frame':
video = item.parent()
return self._container.loadFrame(video['filename'], item['num'])
return self._container.loadFrame(video[image], item['num'])
else:
return self._container.loadImage(item['filename'])
return self._container.loadImage(item[image])

def getAnnotationFilePatterns(self):
return self._container_factory.patterns()
Expand Down Expand Up @@ -448,4 +448,4 @@ def treeview(self):
if self._mainwindow is None:
return None
else:
return self._mainwindow.treeview
return self._mainwindow.treeview
25 changes: 16 additions & 9 deletions sloth/gui/labeltool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#!/usr/bin/python
import matplotlib.pyplot as plt
import matplotlib.image as mpimg

import logging, os
import functools
import fnmatch
Expand Down Expand Up @@ -129,6 +132,12 @@ def onCurrentImageChanged(self):

img = self.labeltool.getImage(new_image)

plt.ion()
img2=self.labeltool.getImage(new_image, 'fwdCam')
imgplot = plt.imshow(img2)
plt.show()
plt.pause(0.01)

if img == None:
self.controls.setFilename("")
self.selectionmodel.setCurrentIndex(new_image.index(), QItemSelectionModel.ClearAndSelect|QItemSelectionModel.Rows)
Expand Down Expand Up @@ -232,10 +241,10 @@ def setupGui(self):

# get inserters and items from labels
# FIXME for handling the new-style config correctly
inserters = dict([(label['attributes']['class'], label['inserter'])
inserters = dict([(label['attributes']['class'], label['inserter'])
for label in config.LABELS
if 'class' in label.get('attributes', {}) and 'inserter' in label])
items = dict([(label['attributes']['class'], label['item'])
items = dict([(label['attributes']['class'], label['item'])
for label in config.LABELS
if 'class' in label.get('attributes', {}) and 'item' in label])

Expand Down Expand Up @@ -301,7 +310,7 @@ def setupGui(self):
self.copyAnnotations = CopyAnnotations(self.labeltool)
self.interpolateRange = InterpolateRange(self.labeltool)

# Show the UI. It is important that this comes *after* the above
# Show the UI. It is important that this comes *after* the above
# adding of custom widgets, especially the central widget. Otherwise the
# dock widgets would be far to large.
self.ui.show()
Expand Down Expand Up @@ -397,7 +406,7 @@ def fileOpen(self):
path = QFileInfo(filename).path()

format_str = ' '.join(self.labeltool.getAnnotationFilePatterns())
fname = QFileDialog.getOpenFileName(self,
fname = QFileDialog.getOpenFileName(self,
"%s - Load Annotations" % APP_NAME, path,
"%s annotation files (%s)" % (APP_NAME, format_str))
if len(str(fname)) > 0:
Expand Down Expand Up @@ -446,20 +455,20 @@ def addMediaFile(self):
for pattern in image_types:
if fnmatch.fnmatch(fname.lower(), pattern):
item = self.labeltool.addImageFile(fname)

progress_bar.setValue(c)

if item is None:
return self.labeltool.addVideoFile(fname)

progress_bar.close()

return item

def onViewsLockedChanged(self, checked):
features = QDockWidget.AllDockWidgetFeatures
if checked:
features = QDockWidget.NoDockWidgetFeatures
features = QDockWidget.NoDockWidgetFeatures

self.ui.dockProperties.setFeatures(features)
self.ui.dockAnnotations.setFeatures(features)
Expand All @@ -481,5 +490,3 @@ def about(self):
was developed at the CVHCI research group at KIT.
<p>For more details, visit our homepage: <a href="%s">%s</a>"""
% (APP_NAME, __version__, ORGANIZATION_DOMAIN, ORGANIZATION_DOMAIN))


6 changes: 6 additions & 0 deletions sloth/gui/labeltool.ui
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@
</attribute>
<widget class="QWidget" name="dockPropertiesContents"/>
</widget>






<widget class="QDockWidget" name="dockAnnotations">
<property name="windowTitle">
<string>Annotations</string>
Expand Down