albumentations-team / albumentations

Fast and flexible image augmentation library. Paper about the library: https://www.mdpi.com/2078-2489/11/2/125
https://albumentations.ai
MIT License
14.26k stars 1.65k forks source link

Feature request: invisible keypoints return with marks #661

Open xjh19971 opened 4 years ago

xjh19971 commented 4 years ago

Thank you for this excellent data augmentation repo! I was wondering if there is one way to return all keypoints but mark those invisible keypoints. This is because the current method can remove invisible keypoints but only return visible keypoints. I want my returned keypoint array to have same length. Could you tell me how to do that in current version or implement this feature in next version? Thanks!

BloodAxe commented 4 years ago

Perhaps, the easiest way would be to disable removal of invisible key points via KeypointParams. After data augmentation step you can quickly compute visibility mask by checking whether points within image boundary.

ср, 15 июля 2020 г. в 3:51 AM, xjh19971 notifications@github.com:

Thank you for this excellent data augmentation repo! I was wondering if there is one way to return all keypoints but mark those invisible keypoints. This is because the current method can remove invisible keypoints but only return visible keypoints. I want my returned keypoint array to have same length. Could you tell me how to do that in current version or implement this feature in next version? Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/albumentations-team/albumentations/issues/661, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAEB6YAXKYURC7XSGK4GBKLR3T4SDANCNFSM4O2BAN3A .

Dipet commented 4 years ago

In the current version, you can do this, as in the example below. I think the current solution is enough.

import albumentations as A
import numpy as np

image = np.zeros([100, 100, 3], dtype=np.uint8)
keypoints = [[0, 0, 1], [50, 50, 2], [90, 90, 3]]
aug = A.Compose([A.Crop(10, 10, 80, 80)], keypoint_params=A.KeypointParams('xy', remove_invisible=False))

res = aug(image=image, keypoints=keypoints)
res_keys = res['keypoints']
res_img = res['image']
print(res_keys)
print([(i[0] < 0 or i[1] < 0 or i[0] >= res_img.shape[1] or i[1] >= res_img.shape[1]) for i in res_keys])
mynameisissac commented 1 year ago

Hi, does this 'boundary checking' solution also work for Affine transformation like rotation, translation or even shearing?