From 491184720b19b565b1b550cc15e8fba16a5d165b Mon Sep 17 00:00:00 2001 From: Martin Baeuml Date: Wed, 14 Sep 2011 18:10:33 +0200 Subject: [PATCH] add generic plugin to copy labels from the previous image/frame (fixes #34) --- sloth/plugins/__init__.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sloth/plugins/__init__.py b/sloth/plugins/__init__.py index e69de29..aef6e13 100644 --- a/sloth/plugins/__init__.py +++ b/sloth/plugins/__init__.py @@ -0,0 +1,22 @@ +from PyQt4.QtGui import * +from PyQt4.QtCore import * + +class CopyAnnotationsPlugin(QObject): + def __init__(self, labeltool): + QObject.__init__(self) + self._labeltool = labeltool + self._wnd = labeltool.mainWindow() + self._sc = QAction("Copy labels from previous image/frame", self._wnd) + self._sc.triggered.connect(self.copy) + + def copy(self): + current = self._labeltool.currentImage() + if current is not None: + prev = current.getPreviousSibling() + if prev is not None: + for annotation in prev.children(): + copied = dict(annotation.iteritems()) + current.addAnnotation(copied) + + def action(self): + return self._sc