-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsize.py
More file actions
24 lines (24 loc) · 1.04 KB
/
Copy pathsize.py
File metadata and controls
24 lines (24 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class CropAndPad(meta.Augmenter):
...
def _augment_keypoints(self, keypoints_on_images, random_state, parents, hooks):
result = []
nb_images = len(keypoints_on_images)
rngs = random_state.duplicate(nb_images)
for keypoints_on_image, rng in zip(keypoints_on_images, rngs):
height, width = keypoints_on_image.shape[0:2]
samples = self._draw_samples_image(rng, height, width)
kpsoi_aug = _crop_and_pad_kpsoi(
keypoints_on_image, croppings_img=samples.croppings,
paddings_img=samples.paddings, keep_size=self.keep_size)
result.append(kpsoi_aug)
return result
...
def _crop_and_pad_kpsoi(kpsoi, croppings_img, paddings_img, keep_size):
shifted = kpsoi.shift(
x=-croppings_img[3]+paddings_img[3],
y=-croppings_img[0]+paddings_img[0])
shifted.shape = _compute_shape_after_crop_and_pad(
kpsoi.shape, croppings_img, paddings_img)
if keep_size:
shifted = shifted.on(kpsoi.shape)
return shifted