Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Fix bug in flip_bbox with xyxy format #2598

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading