-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransformers.py
More file actions
26 lines (20 loc) · 798 Bytes
/
Copy pathtransformers.py
File metadata and controls
26 lines (20 loc) · 798 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import numpy as np
import random
class PointSampler(object):
def __init__(self, output_size):
self.output_size = output_size
def __call__(self, input):
assert input[0].shape[0] >= self.output_size
indices = np.random.choice(input[0].shape[0], self.output_size)
return (input[0][indices], input[1][indices])
class RandomRotation(object):
def __call__(self, input):
pointcloud, categories = input[0], input[1]
theta = random.random() * 2 * np.pi # Rotation angle
rotation_mat = np.array([
[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0],
[0, 0, 1]
])
rotated_pointcloud = rotation_mat.dot(pointcloud.T).T
return (rotated_pointcloud, categories)