{"record":{"id":"517df3e980a95b13","repo":"roboflow/supervision","slug":"cannot-use-position-center-of-mass-without-a-det","errorCode":null,"errorMessage":"Cannot use `Position.CENTER_OF_MASS` without a detection mask.","messagePattern":"Cannot use `Position\\.CENTER_OF_MASS` without a detection mask\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/core.py","lineNumber":2589,"sourceCode":"                    np.asarray(self.data[ORIENTED_BOX_COORDINATES]), anchor\n                ),\n            )\n\n        xyxy = self.xyxy\n\n        def coordinates(\n            x: npt.NDArray[np.number], y: npt.NDArray[np.number]\n        ) -> npt.NDArray[np.generic]:\n            return cast(npt.NDArray[np.generic], np.array([x, y]).transpose())\n\n        if anchor == Position.CENTER:\n            return coordinates(\n                (xyxy[:, 0] + xyxy[:, 2]) / 2,\n                (xyxy[:, 1] + xyxy[:, 3]) / 2,\n            )\n        elif anchor == Position.CENTER_OF_MASS:\n            if self.mask is None:\n                raise ValueError(\n                    \"Cannot use `Position.CENTER_OF_MASS` without a detection mask.\"\n                )\n            return calculate_masks_centroids(masks=self.mask)\n        elif anchor == Position.CENTER_LEFT:\n            return coordinates(xyxy[:, 0], (xyxy[:, 1] + xyxy[:, 3]) / 2)\n        elif anchor == Position.CENTER_RIGHT:\n            return coordinates(xyxy[:, 2], (xyxy[:, 1] + xyxy[:, 3]) / 2)\n        elif anchor == Position.BOTTOM_CENTER:\n            return coordinates((xyxy[:, 0] + xyxy[:, 2]) / 2, xyxy[:, 3])\n        elif anchor == Position.BOTTOM_LEFT:\n            return coordinates(xyxy[:, 0], xyxy[:, 3])\n        elif anchor == Position.BOTTOM_RIGHT:\n            return coordinates(xyxy[:, 2], xyxy[:, 3])\n        elif anchor == Position.TOP_CENTER:\n            return coordinates((xyxy[:, 0] + xyxy[:, 2]) / 2, xyxy[:, 1])\n        elif anchor == Position.TOP_LEFT:\n            return coordinates(xyxy[:, 0], xyxy[:, 1])\n        elif anchor == Position.TOP_RIGHT:","sourceCodeStart":2571,"sourceCodeEnd":2607,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/core.py#L2571-L2607","documentation":"Error \"Cannot use `Position.CENTER_OF_MASS` without a detection mask.\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/detection/core.py:2589 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use Position.CENTER_OF_MASS only with Detections that include a mask; otherwise choose a box-based position such as Position.CENTER.","If masks are available from your model, make sure they are passed into the Detections constructor."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}