-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
39 lines (28 loc) · 764 Bytes
/
utils.py
File metadata and controls
39 lines (28 loc) · 764 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
27
28
29
30
31
32
33
34
35
36
37
38
import numpy as np
import random
import os
def random_view():
choice = [
np.array((1, 0, 0), dtype=np.float32),
np.array((0, 0, 1), dtype=np.float32),
np.array((1, 0, 1), dtype=np.float32),
np.array((-1, 0, 0), dtype=np.float32),
np.array((-1, 1, 0), dtype=np.float32),
]
# Randomly choose a viewpoint.
return random.sample(choice, 1)
def distance_to_point(arr, point):
tmp = arr - point
return np.sum(tmp * tmp, axis=1)
def tf_distance_to_point(arr, point):
tmp = arr - point
return tf.reduce_sum(tmp * tmp, axis=1)
def size_from_shape(shape):
t = 1
for x in shape:
t *= x
return t
def index_from_file(fname):
fname = os.path.basename(fname)
str_id = fname.split('.')[0]
return int(str_id)