MCPcopy Create free account
hub / github.com/InternRobotics/EmbodiedScan / xywhr2xyxyr

Function xywhr2xyxyr

embodiedscan/structures/bbox_3d/utils.py:186–205  ·  view source on GitHub ↗

Convert a rotated boxes in XYWHR format to XYXYR format. Args: boxes_xywhr (Tensor or np.ndarray): Rotated boxes in XYWHR format. Returns: Tensor or np.ndarray: Converted boxes in XYXYR format.

(
        boxes_xywhr: Union[Tensor, np.ndarray])

Source from the content-addressed store, hash-verified

184
185@array_converter(apply_to=('boxes_xywhr', ))
186def xywhr2xyxyr(
187 boxes_xywhr: Union[Tensor, np.ndarray]) -> Union[Tensor, np.ndarray]:
188 """Convert a rotated boxes in XYWHR format to XYXYR format.
189
190 Args:
191 boxes_xywhr (Tensor or np.ndarray): Rotated boxes in XYWHR format.
192
193 Returns:
194 Tensor or np.ndarray: Converted boxes in XYXYR format.
195 """
196 boxes = torch.zeros_like(boxes_xywhr)
197 half_w = boxes_xywhr[..., 2] / 2
198 half_h = boxes_xywhr[..., 3] / 2
199
200 boxes[..., 0] = boxes_xywhr[..., 0] - half_w
201 boxes[..., 1] = boxes_xywhr[..., 1] - half_h
202 boxes[..., 2] = boxes_xywhr[..., 0] + half_w
203 boxes[..., 3] = boxes_xywhr[..., 1] + half_h
204 boxes[..., 4] = boxes_xywhr[..., 4]
205 return boxes
206
207
208def get_box_type(box_type: str) -> Tuple[type, int]:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected