MCPcopy Create free account
hub / github.com/MetaSLAM/SphereVLAD / SphRandomRotate

Class SphRandomRotate

dataloader/data_augmentation.py:95–117  ·  view source on GitHub ↗

Random rotate spherical projection of point cloud

Source from the content-addressed store, hash-verified

93
94
95class SphRandomRotate:
96 '''Random rotate spherical projection of point cloud'''
97 def __init__(self, p, img_size):
98 assert 0 < p <= 1, 'probability must be in (0, 1] range)!'
99 self.p = p
100 self.grid = get_projection_grid(b=(int)(img_size[0]/2.0))
101
102 def __call__(self, sph_img):
103 #* conver from PIL.Image into numpy.array
104 signals = np.expand_dims(np.array(sph_img), axis=0)
105 #* generate random rotation along all three axis
106 rot = rand_rotation_matrix(deflection=1)
107 #* generate random rotation along z-axis
108 # rot_angle = 2*np.pi*random.uniform(1)
109 # cosval = np.cos(rot_angle)
110 # sinval = np.sin(rot_angle)
111 # rot = np.array([[cosval, -sinval, 0],
112 # [sinval, cosval, 0],
113 # [0, 0, 1]])
114 rotated_grid = rotate_grid(rot, self.grid)
115 rot_sph_img = project_2d_on_sphere(signals, rotated_grid, projection_origin=[0,0,0.00001])
116 rot_sph_img = np.squeeze(rot_sph_img)
117 return rot_sph_img
118
119
120class RandomFlip:

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected