MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / __call__

Method __call__

detrsmpl/data/datasets/pipelines/transforms.py:1024–1134  ·  view source on GitHub ↗
(self, results)

Source from the content-addressed store, hash-verified

1022 self.max_size = max_size
1023
1024 def __call__(self, results):
1025 ori_shape = np.array(results['ori_shape'])
1026 # ori_shape = ori_shape[::-1]
1027 # print(ori_shape)
1028 size = random.choice(self.sizes)
1029 reshape_size = resize(ori_shape, size, self.max_size)
1030 c = (ori_shape / 2)[::-1]
1031 s = ori_shape[::-1]
1032 r = results['rotation']
1033
1034 trans = get_affine_transform(c, s, r, reshape_size[::-1])
1035
1036 results['img_shape'] = reshape_size
1037 if 'img' in results:
1038 img = results['img'].copy()
1039
1040 # img before affine
1041 ori_img = img.copy()
1042 results['crop_transform'] = trans
1043 results['ori_img'] = ori_img
1044 results['img_fields'] = ['img', 'ori_img']
1045
1046 img = cv2.warpAffine(img,
1047 trans,
1048 (int(reshape_size[1]), int(reshape_size[0])),
1049 flags=cv2.INTER_LINEAR)
1050 results['img'] = img
1051
1052 if 'keypoints2d_ori' in results:
1053 keypoints2d_ori = results['keypoints2d_ori'].copy()
1054
1055 results['keypoints2d_ori'][..., :2] = affine_transform(
1056 keypoints2d_ori, trans)
1057
1058 if 'keypoints2d_smpl' in results:
1059 keypoints2d_smpl = results['keypoints2d_smpl'].copy()
1060
1061 results['keypoints2d_smpl'][..., :2] = affine_transform(
1062 keypoints2d_smpl, trans)
1063
1064 if 'bbox_xywh' in results:
1065 bbox_xywh = results['bbox_xywh'].copy()
1066
1067 leftTop = bbox_xywh[..., :2]
1068 rightTop = np.concatenate([
1069 bbox_xywh[..., [0]] + bbox_xywh[..., [2]], bbox_xywh[..., [1]]
1070 ], -1)
1071 leftBottom = np.concatenate([
1072 bbox_xywh[..., [0]], bbox_xywh[..., [1]] + bbox_xywh[..., [3]]
1073 ], -1)
1074 rightBottom = np.concatenate([
1075 bbox_xywh[..., [0]] + bbox_xywh[..., [2]],
1076 bbox_xywh[..., [1]] + bbox_xywh[..., [3]]
1077 ], -1)
1078
1079 bbox_point = np.vstack(
1080 [leftTop, rightTop, leftBottom, rightBottom])
1081 bbox_point = np.concatenate(

Callers

nothing calls this directly

Calls 8

xyxy2xywhFunction · 0.90
get_affine_transformFunction · 0.85
affine_transformFunction · 0.85
_rotate_joints_3dFunction · 0.85
_rotate_smpl_poseFunction · 0.85
copyMethod · 0.80
concatenateMethod · 0.80
resizeFunction · 0.70

Tested by

no test coverage detected