def check_coordinate_transforms(): example = dataset[keys] p3w = example['p3w'] p3c = example['p3c'] r = example.attrs['r'] t = example.attrs['t'] transformed = np_impl.transform_frame(p3w, r, t) print(np.max(np.abs(transformed - p3c)), np.max(np.abs(p3c)))
def __getitem__(self, key): if key == 'p3w': p3c = self['p3c'] r = self.attrs['r'] t = self.attrs['t'] return np_impl.transform_frame(p3c, r, t, inverse=True) return self._converter.convert( self._group[MpiInfExample._group_map[key]][self._camera])
def _test_example_transforms(self, example): p3w, p3c, r, t = (example[k] for k in ['p3w', 'p3c', 'r', 't']) actual_p3c = transform_frame(p3w, r, t) np.testing.assert_allclose(actual_p3c, p3c, atol=1.0)
def apply_consistent_pose(sequence): p3w = sequence['p3w'] r, t = (sequence.attrs[k] for k in ['r', 't']) sequence['p3c'] = np_impl.transform_frame(p3w, r=r, t=t)
def p2(self): return np_impl.transform_frame(self.p3c, f=self.f, c=self.c) / self.pixel_scale
def p3c(self): return np_impl.transform_frame(self.p3w, r=self.r, t=self.t)
# raise Exception('Unrecognized skeleton, %s' % skeleton) # else: # return dataset if __name__ == '__main__': import numpy as np from human_pose_util.skeleton import vis3d, vis2d from human_pose_util.transforms.np_impl import transform_frame from human_pose_util.transforms.np_impl import project from skeleton import s14 # from skeleton import s16 from skeleton import s20 import matplotlib.pyplot as plt # dataset = human_eva_dataset(skeleton=s16) example = get_example(list(train_ids())[0]).map( {k: s20.to_s14 for k in ['p2', 'p3c', 'p3w']}) p3w, p3c, p2, r, t, f, c = example['p3w', 'p3c', 'p2', 'r', 't', 'f', 'c'] p3w = p3w[0] p3c = p3c[0] p2 = p2[0] p3c2 = transform_frame(p3w, r, t) print(np.max(np.abs(p3c - p3c2)) / np.max(np.abs(p3c))) p22 = project(p3c, f, c) print(np.max(np.abs(p22 - p2)) / np.max(np.abs(p2))) skeleton = s14 vis3d(skeleton, p3w) vis3d(skeleton, p3c) vis2d(skeleton, p2) plt.show()