Last active
May 28, 2020 01:51
-
-
Save yongjun823/f548ea4bf6422096904641710a3590a2 to your computer and use it in GitHub Desktop.
point cloud voxel style split
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from itertools import product | |
# voxel range | |
range_size = 11 | |
x_lin = np.linspace(-1.5, 1.5, range_size) | |
y_lin = np.linspace(-1.5, 1.5, range_size) | |
z_lin = np.linspace(-1.5, 1.5, range_size) | |
xyz_range = list(product(list(range(range_size-1)), | |
list(range(range_size-1)), | |
list(range(range_size-1)))) | |
def count_voxel(file_path): | |
# load test data | |
test_data = np.load(file_path) | |
# check min max of point cloud | |
print(np.max(test_data)) | |
print(np.min(test_data)) | |
for test in test_data: | |
ss = 0 | |
cnt_arr = [] | |
# count how much point in x y z range | |
for x_idx, y_idx, z_idx in xyz_range: | |
t = test[(x_lin[x_idx] <= test[:, 0]) & (test[:, 0] < x_lin[x_idx+1])] | |
t = t[(y_lin[y_idx] <= t[:, 1]) & (t[:, 1] < y_lin[y_idx+1])] | |
t = t[(z_lin[z_idx] <= t[:, 2]) & (t[:, 2] < z_lin[z_idx+1])] | |
cnt_arr.append(t.shape[0]) | |
print(np.sum(cnt_arr) == 2048) | |
return cnt_arr | |
count_voxel('Results/train_point_class_part3/images/shape16_test_encoder3d.npy') | |
count_voxel('Results/train_point_class_part3/images/shape16_test_data.npy') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment