upd
This commit is contained in:
11
utils/pts.py
11
utils/pts.py
@@ -16,6 +16,17 @@ class PtsUtil:
|
||||
else:
|
||||
unique_voxels = np.unique(voxel_indices, axis=0, return_inverse=True)
|
||||
return unique_voxels[0]*voxel_size
|
||||
|
||||
@staticmethod
|
||||
def voxel_downsample_point_cloud_random(point_cloud, voxel_size=0.005, require_idx=False):
|
||||
voxel_indices = np.floor(point_cloud / voxel_size).astype(np.int32)
|
||||
unique_voxels, inverse, counts = np.unique(voxel_indices, axis=0, return_inverse=True, return_counts=True)
|
||||
idx_sort = np.argsort(inverse)
|
||||
idx_unique = idx_sort[np.cumsum(counts)-counts]
|
||||
downsampled_points = point_cloud[idx_unique]
|
||||
if require_idx:
|
||||
return downsampled_points, inverse
|
||||
return downsampled_points
|
||||
|
||||
@staticmethod
|
||||
def random_downsample_point_cloud(point_cloud, num_points, require_idx=False):
|
||||
|
@@ -1,6 +1,7 @@
|
||||
|
||||
import os
|
||||
import json
|
||||
import time
|
||||
import subprocess
|
||||
import tempfile
|
||||
import shutil
|
||||
@@ -68,9 +69,13 @@ class RenderUtil:
|
||||
params_data_path = os.path.join(temp_dir, "params.json")
|
||||
with open(params_data_path, 'w') as f:
|
||||
json.dump(params, f)
|
||||
start_time = time.time()
|
||||
result = subprocess.run([
|
||||
'blender', '-b', '-P', script_path, '--', temp_dir
|
||||
], capture_output=True, text=True)
|
||||
end_time = time.time()
|
||||
print(result)
|
||||
print(f"-- Time taken for blender: {end_time - start_time} seconds")
|
||||
if result.returncode != 0:
|
||||
print("Blender script failed:")
|
||||
print(result.stderr)
|
||||
@@ -82,6 +87,7 @@ class RenderUtil:
|
||||
cam_info["far_plane"],
|
||||
binocular=True
|
||||
)
|
||||
start_time = time.time()
|
||||
mask_L, mask_R = DataLoadUtil.load_seg(path, binocular=True)
|
||||
normal_L = DataLoadUtil.load_normal(path, binocular=True, left_only=True)
|
||||
''' target points '''
|
||||
@@ -114,6 +120,7 @@ class RenderUtil:
|
||||
if not has_points:
|
||||
target_points = np.zeros((0, 3))
|
||||
target_normals = np.zeros((0, 3))
|
||||
|
||||
end_time = time.time()
|
||||
print(f"-- Time taken for processing: {end_time - start_time} seconds")
|
||||
#import ipdb; ipdb.set_trace()
|
||||
return target_points, target_normals
|
Reference in New Issue
Block a user