Skip to content

Commit

Permalink
[Fix] fix bug in flip_bbox with xyxy format (#2598)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Louis authored Aug 4, 2023
1 parent 55bb3e8 commit a2769aa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mmpose/structures/bbox/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,17 +209,19 @@ def flip_bbox(bbox: np.ndarray,
if bbox_format == 'xywh' or bbox_format == 'center':
bbox_flipped[..., 0] = w - bbox[..., 0] - 1
elif bbox_format == 'xyxy':
bbox_flipped[..., ::2] = w - bbox[..., ::2] - 1
bbox_flipped[..., ::2] = w - bbox[..., -2::-2] - 1
elif direction == 'vertical':
if bbox_format == 'xywh' or bbox_format == 'center':
bbox_flipped[..., 1] = h - bbox[..., 1] - 1
elif bbox_format == 'xyxy':
bbox_flipped[..., 1::2] = h - bbox[..., 1::2] - 1
bbox_flipped[..., 1::2] = h - bbox[..., ::-2] - 1
elif direction == 'diagonal':
if bbox_format == 'xywh' or bbox_format == 'center':
bbox_flipped[..., :2] = [w, h] - bbox[..., :2] - 1
elif bbox_format == 'xyxy':
bbox_flipped[...] = [w, h, w, h] - bbox - 1
bbox_flipped = np.concatenate(
(bbox_flipped[..., 2:], bbox_flipped[..., :2]), axis=-1)

return bbox_flipped

Expand Down

0 comments on commit a2769aa

Please sign in to comment.