From d5f629d806ddbd303acb6a1c0807d3e1b0d62309 Mon Sep 17 00:00:00 2001 From: Mika Fischer Date: Tue, 7 Jun 2011 16:31:18 +0200 Subject: [PATCH] Add FileNameListContainer It can be used to initialize the list of images to be annotated. --- sloth/annotations/container.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sloth/annotations/container.py b/sloth/annotations/container.py index 6f52599..e955e0e 100644 --- a/sloth/annotations/container.py +++ b/sloth/annotations/container.py @@ -224,6 +224,31 @@ class YamlContainer(AnnotationContainer): yaml.dump(self.annotations(), f) +class FileNameListContainer(AnnotationContainer): + """ + Simple container to initialize the files to be annotated. + """ + + def parseFromFile(self, filename): + self.basedir_ = os.path.dirname(filename) + f = open(filename, "r") + print "Opening", filename + + annotations = [] + for line in f: + line = line.strip() + fileitem = { + 'filename': line, + 'type': 'image', + 'annotations': [], + } + annotations.append(fileitem) + + return annotations + + def serializeToFile(self, filename): + raise NotImplemented("FileNameListContainer.save() is not implemented yet.") + class FeretContainer(AnnotationContainer): """ Container for Feret labels.