Skip to content

Commit 11306ff

Browse files
committed
Quantize bboxes
1 parent c394ad1 commit 11306ff

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

labelbox/exporters/pascal_voc_writer/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,12 @@ def add_object(self, name, xy_coords):
3838
if len(xy_coords) == 8:
3939
x_points = sorted(xy_coords[::2])
4040
y_points = sorted(xy_coords[1::2])
41-
if (x_points[0] == x_points[1] and x_points[2] == x_points[3]
42-
and y_points[0] == y_points[1] and y_points[2] == y_points[3]):
41+
42+
# quantize up to 1 px off to bounding boxes
43+
if (abs(x_points[0] - x_points[1]) < 1 and abs(x_points[2] - x_points[3]) < 1
44+
and abs(y_points[0] == y_points[1]) < 1 and abs(y_points[2] == y_points[3]) < 1:
45+
x_points[0] = x_points[1]
46+
x_points[2] = x_points[3]
4347
label_type = 'bndbox'
4448
else:
4549
label_type = 'polygon'

0 commit comments

Comments
 (0)