Skip to content

Commit

Permalink
added float parsing before int conversion to enable support of VOC fi…
Browse files Browse the repository at this point in the history
…les that specify coordinates in float
  • Loading branch information
Joakim Eriksson authored and tzutalin committed Jan 5, 2019
1 parent 4bb6be6 commit c2aca6e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libs/pascal_voc_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ def appendObjects(self, top):
pose = SubElement(object_item, 'pose')
pose.text = "Unspecified"
truncated = SubElement(object_item, 'truncated')
if int(each_object['ymax']) == int(self.imgSize[0]) or (int(each_object['ymin'])== 1):
if int(float(each_object['ymax'])) == int(float(self.imgSize[0])) or (int(float(each_object['ymin']))== 1):
truncated.text = "1" # max == height or min
elif (int(each_object['xmax'])==int(self.imgSize[1])) or (int(each_object['xmin'])== 1):
elif (int(float(each_object['xmax']))==int(float(self.imgSize[1]))) or (int(float(each_object['xmin']))== 1):
truncated.text = "1" # max == width or min
else:
truncated.text = "0"
Expand Down Expand Up @@ -141,10 +141,10 @@ def getShapes(self):
return self.shapes

def addShape(self, label, bndbox, difficult):
xmin = int(bndbox.find('xmin').text)
ymin = int(bndbox.find('ymin').text)
xmax = int(bndbox.find('xmax').text)
ymax = int(bndbox.find('ymax').text)
xmin = int(float(bndbox.find('xmin').text))
ymin = int(float(bndbox.find('ymin').text))
xmax = int(float(bndbox.find('xmax').text))
ymax = int(float(bndbox.find('ymax').text))
points = [(xmin, ymin), (xmax, ymin), (xmax, ymax), (xmin, ymax)]
self.shapes.append((label, points, None, None, difficult))

Expand Down

0 comments on commit c2aca6e

Please sign in to comment.