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

Extra keypoints when using Rotate with keypoints #2055

Closed
Chxresubles opened this issue Nov 4, 2024 · 1 comment
Closed

Extra keypoints when using Rotate with keypoints #2055

Chxresubles opened this issue Nov 4, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Chxresubles
Copy link

Describe the bug

Using A.Rotate in A.Compose with remove_invisible=False returns 9 times more keypoints than the input number of keypoints.

To Reproduce

Steps to reproduce the behavior:

import numpy as np
import albumentations as A

image = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)
keypoints = np.random.randint(0, 100, (50, 2), dtype=np.uint8)

# Check shape
print(keypoints.shape)  # (50, 2)

result = A.Compose([A.Rotate(limit=45, p=1.0)], keypoint_params=A.KeypointParams(format='yx', remove_invisible=False))(image=image, keypoints=keypoints)

# Check shape
print(result['keypoints'].shape)  # (450, 2)

Expected behavior

result['keypoints'] should have the same shape as the input keypoints. (50, 2)

Actual behavior

result['keypoints'] has 9 times more keypoints than the input keypoints. (9 * 50, 2)

Additional context

The bug was not present in albumentations==1.4.18 and was introduced since albumentations==1.4.19

@Chxresubles Chxresubles added the bug Something isn't working label Nov 4, 2024
@ternaus
Copy link
Collaborator

ternaus commented Nov 4, 2024

It is not a bug, but a feature.

When you use border_mode=cv2.BORDER_REFLECT_101 which is the default, you get new keypoints in the reflected regions.

If you change border_mode to cv2.BORDER_CONSTANT, no new keypoints will be added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants