diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ea7fb084c56..6e438bbaf839 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Invalid mask when running automatic annotation on a task () - Cloud storage content listing when the manifest name contains special characters () +- Width and height in CVAT dataset format mask annotations () ### Security - TDB diff --git a/cvat/apps/dataset_manager/formats/cvat.py b/cvat/apps/dataset_manager/formats/cvat.py index 854659774bb8..c3a7f708aeec 100644 --- a/cvat/apps/dataset_manager/formats/cvat.py +++ b/cvat/apps/dataset_manager/formats/cvat.py @@ -795,8 +795,8 @@ def dump_labeled_shapes(shapes, is_skeleton=False): ("rle", f"{list(int (v) for v in shape.points[:-4])}"[1:-1]), ("left", f"{int(shape.points[-4])}"), ("top", f"{int(shape.points[-3])}"), - ("width", f"{int(shape.points[-2] - shape.points[-4])}"), - ("height", f"{int(shape.points[-1] - shape.points[-3])}"), + ("width", f"{int(shape.points[-2] - shape.points[-4]) + 1}"), + ("height", f"{int(shape.points[-1] - shape.points[-3]) + 1}"), ])) elif shape.type != 'skeleton': dump_data.update(OrderedDict([ @@ -933,8 +933,8 @@ def dump_shape(shape, element_shapes=None, label=None): ("rle", f"{list(int (v) for v in shape.points[:-4])}"[1:-1]), ("left", f"{int(shape.points[-4])}"), ("top", f"{int(shape.points[-3])}"), - ("width", f"{int(shape.points[-2] - shape.points[-4])}"), - ("height", f"{int(shape.points[-1] - shape.points[-3])}"), + ("width", f"{int(shape.points[-2] - shape.points[-4]) + 1}"), + ("height", f"{int(shape.points[-1] - shape.points[-3]) + 1}"), ])) elif shape.type == "cuboid": dump_data.update(OrderedDict([ @@ -1293,8 +1293,8 @@ def load_anno(file_object, annotations): shape['points'] = el.attrib['rle'].split(',') shape['points'].append(el.attrib['left']) shape['points'].append(el.attrib['top']) - shape['points'].append("{}".format(int(el.attrib['left']) + int(el.attrib['width']))) - shape['points'].append("{}".format(int(el.attrib['top']) + int(el.attrib['height']))) + shape['points'].append("{}".format(int(el.attrib['left']) + int(el.attrib['width']) - 1)) + shape['points'].append("{}".format(int(el.attrib['top']) + int(el.attrib['height']) - 1)) elif el.tag == 'cuboid': shape['points'].append(el.attrib['xtl1']) shape['points'].append(el.attrib['ytl1']) diff --git a/site/content/en/docs/manual/advanced/xml_format.md b/site/content/en/docs/manual/advanced/xml_format.md index 8efab34c1828..1c983e3d8275 100644 --- a/site/content/en/docs/manual/advanced/xml_format.md +++ b/site/content/en/docs/manual/advanced/xml_format.md @@ -38,7 +38,7 @@ In annotation mode each image tag has `width` and `height` attributes for the sa