From b0bb8d05686688f9f110c10f4eb961f3322e732b Mon Sep 17 00:00:00 2001 From: Martin Baeuml Date: Thu, 9 Dec 2010 17:18:57 +0100 Subject: [PATCH] write one line for each rect --- annotations.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/annotations.py b/annotations.py index d9bc1fb..0358541 100644 --- a/annotations.py +++ b/annotations.py @@ -48,18 +48,21 @@ class AnnotationContainer: except Exception as e: self.annotations = [] raise e - + + def save(self, filename): + self.saveRectFormat(filename) def saveRectFormat(self, filename): - f = open(filname, "w") + f = open(filename, "w") for file in self.annotations_: if file['type'] == 'image': rect_anns = [ann for ann in file['annotations'] if ann['type'] == 'rect'] - f.write("%s %d", file['filename'], len(rect_anns)) + #f.write("%s %d", file['filename'], len(rect_anns)) for ann in rect_anns: - f.write(' %s %s %s %s', str(ann['x']), str(ann['y']), str(ann['width']), str(ann['height'])) - f.write('\n') + f.write('%s 1 %s %s %s %s\n' % (file['filename'], str(ann['x']), str(ann['y']), str(ann['width']), str(ann['height']))) + + self.filename_ = filename def asDict(self): return self.annotations_