{"record":{"id":"fa7984a3651f4df1","repo":"roboflow/supervision","slug":"missing-polygon-coordinate-value-in-pascal-voc","errorCode":null,"errorMessage":"Missing polygon coordinate value in Pascal VOC.","messagePattern":"Missing polygon coordinate value in Pascal VOC\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/dataset/formats/pascal_voc.py","lineNumber":387,"sourceCode":"\n    annotation = Detections(\n        xyxy=xyxy_arr,\n        mask=mask_arr,\n        class_id=class_id,\n    )\n\n    return annotation, extended_classes\n\n\ndef _with_poly_mask(obj: Element) -> bool:\n    return obj.find(\"polygon\") is not None\n\n\ndef parse_polygon_points(polygon: Element) -> npt.NDArray[np.int_]:\n    coordinates: list[int] = []\n    for coord in polygon.findall(\".//*\"):\n        if coord.text is None:\n            raise ValueError(\"Missing polygon coordinate value in Pascal VOC.\")\n        coordinates.append(int(coord.text))\n    return np.array(\n        [(coordinates[i], coordinates[i + 1]) for i in range(0, len(coordinates), 2)],\n        dtype=int,\n    )\n\n\ndef _get_required_text(element: Element, tag: str) -> str:\n    child = element.find(tag)\n    if child is None or child.text is None:\n        raise ValueError(f\"Missing '{tag}' in Pascal VOC annotation.\")\n    return child.text\n\n\ndef save_pascal_voc_annotations(\n    dataset: \"DetectionDataset\",\n    annotations_directory_path: str,\n    min_image_area_percentage: float = 0.0,","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/dataset/formats/pascal_voc.py#L369-L405","documentation":"Raised by parse_polygon_points when iterating the descendants of a <polygon> element and a coordinate tag has no text content (coord.text is None). Pascal VOC polygon extensions expect alternating x/y leaf tags with integer text; an empty tag such as <x></x> makes the integer coordinate unreadable, so parsing aborts.","triggerScenarios":"Loading a Pascal VOC dataset with force_masks=True, or where any object has a <polygon> child, and one of the coordinate sub-elements is empty (e.g. <x/>) or contains only a comment/whitespace-only structure that ElementTree reports as None text.","commonSituations":"Hand-edited polygons; export tools that write self-closing coordinate tags for missing values; partially written annotations from a crashed annotator; datasets converted from other formats with missing numeric fields.","solutions":["Inspect the polygon block of the failing annotation for empty or self-closing coordinate tags.","Fill in the missing integer coordinate or remove the incomplete <polygon> element.","If the whole object is bad, delete the <object> and re-annotate that image.","Re-export from the source annotation tool after fixing the polygon there."],"exampleFix":"<!-- before -->\n<polygon><x>10</x><y></y><x>50</x><y>60</y></polygon>\n<!-- after -->\n<polygon><x>10</x><y>20</y><x>50</x><y>60</y></polygon>","handlingStrategy":"validation","validationCode":"import xml.etree.ElementTree as ET\n\ndef polygon_coords_complete(xml_path: str) -> bool:\n    \"\"\"Check every polygon coordinate leaf has non-empty integer text.\"\"\"\n    root = ET.parse(xml_path).getroot()\n    for poly in root.iter('polygon'):\n        for coord in poly.findall('.//*'):\n            if coord.text is None or not coord.text.strip().lstrip('-').isdigit():\n                return False\n    return True","typeGuard":null,"tryCatchPattern":"try:\n    dataset = sv.DetectionDataset.from_pascal_voc(images_dir, ann_dir)\nexcept ValueError as e:\n    if 'Missing polygon coordinate' in str(e):\n        raise RuntimeError(f'Incomplete polygon in {xml_path}: {e}') from e\n    raise","preventionTips":["Validate polygon blocks when hand-editing VOC XML (every leaf needs integer text).","Test converter output on a few files before batch conversion.","Keep even coordinate counts: x/y pairs must alternate."],"tags":["pascal-voc","dataset","polygon","xml"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}