I need a tool to annotate images with a rectangular bounding box. The output is going to be in pascal voc xml format. Annotations and images will be part of a training dataset used by a convolutional neural net to do object detection. I will annotate the images manually myself.
I've considered the following tools but they don't support pascal-voc.
Labelme, Sloth, Pilab, No name
Is there a annotation tool that will save me time?
This python code snippet will convert Sloth json to pascal voc xml.
def make_anno():
zind = 0
for z in data:
print zind
filename = data[zind]["filename"]
print filename
head, tail = os.path.split(filename)
basename, file_extension = os.path.splitext(tail)
f = open(basename + '.xml','w')
line = "<annotation>" + '\n'
f.write(line)
line = '\t\t<folder>' + "folder" + '</folder>' + '\n'
f.write(line)
line = '\t\t<filename>' + tail + '</filename>' + '\n'
f.write(line)
line = '\t\t<source>\n\t\t<database>Source</database>\n\t</source>\n'
f.write(line)
im=Image.open('/home/location/VOCdevkit/newdataset/img/' + tail)
(width, height) = im.size
line = '\t<size>\n\t\t<width>'+ str(width) + '</width>\n\t\t<height>' + str(height) + '</height>\n\t'
line += '\t<depth>Unspecified</depth>\n\t</size>'
f.write(line)
line = '\n\t<segmented>Unspecified</segmented>'
f.write(line)
ind = 0
for i in data[zind]["annotations"]:
line = '\n\t<object>'
line += '\n\t\t<name>Name</name>\n\t\t<pose>Unspecified</pose>'
line += '\n\t\t<truncated>Unspecified</truncated>\n\t\t<difficult>Unspecified</difficult>'
xmin = (data[zind]["annotations"][ind]["x"])
line += '\n\t\t<bndbox>\n\t\t\t<xmin>' + str(xmin) + '</xmin>'
ymin = (data[zind]["annotations"][ind]["y"])
line += '\n\t\t\t<ymin>' + str(ymin) + '</ymin>'
width = (data[zind]["annotations"][ind]["width"])
height = (data[zind]["annotations"][ind]["height"])
xmax = xmin + width
ymax = ymin + height
line += '\n\t\t\t<xmax>' + str(xmax) + '</xmax>'
line += '\n\t\t\t<ymax>' + str(ymax) + '</ymax>'
line += '\n\t\t</bndbox>'
line += '\n\t</object>'
f.write(line)
ind +=1
f.close()
zind +=1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With