MCPcopy
hub / github.com/SizheAn/PanoHead / create_samples

Function create_samples

gen_videos_interp.py:43–65  ·  view source on GitHub ↗
(N=256, voxel_origin=[0, 0, 0], cube_length=2.0)

Source from the content-addressed store, hash-verified

41 return img
42
43def create_samples(N=256, voxel_origin=[0, 0, 0], cube_length=2.0):
44 # NOTE: the voxel_origin is actually the (bottom, left, down) corner, not the middle
45 voxel_origin = np.array(voxel_origin) - cube_length/2
46 voxel_size = cube_length / (N - 1)
47
48 overall_index = torch.arange(0, N ** 3, 1, out=torch.LongTensor())
49 samples = torch.zeros(N ** 3, 3)
50
51 # transform first 3 columns
52 # to be the x, y, z index
53 samples[:, 2] = overall_index % N
54 samples[:, 1] = (overall_index.float() / N) % N
55 samples[:, 0] = ((overall_index.float() / N) / N) % N
56
57 # transform first 3 columns
58 # to be the x, y, z coordinate
59 samples[:, 0] = (samples[:, 0] * voxel_size) + voxel_origin[2]
60 samples[:, 1] = (samples[:, 1] * voxel_size) + voxel_origin[1]
61 samples[:, 2] = (samples[:, 2] * voxel_size) + voxel_origin[0]
62
63 num_samples = N ** 3
64
65 return samples.unsqueeze(0), voxel_origin, voxel_size
66
67#----------------------------------------------------------------------------
68

Callers 1

gen_interp_videoFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected