|
|
|
|
@ -23,7 +23,7 @@ compute_bbox_out
@@ -23,7 +23,7 @@ compute_bbox_out
|
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
def compute_bbox_out(mesh_obj): |
|
|
|
|
return compute_bbox(mesh_obj) |
|
|
|
|
return compute_bbox_ext(mesh_obj) |
|
|
|
|
|
|
|
|
|
# -------------------------- 结束:获取bbox数据 -------------------------- |
|
|
|
|
|
|
|
|
|
@ -423,12 +423,12 @@ def compute_bbox_all(dict_mesh_obj,is_downsample):
@@ -423,12 +423,12 @@ def compute_bbox_all(dict_mesh_obj,is_downsample):
|
|
|
|
|
obj_name = key |
|
|
|
|
mesh_obj = value |
|
|
|
|
|
|
|
|
|
total_matrix, min_bound, max_bound, pcd_fix, ply_name = compute_bbox(mesh_obj,obj_name,is_downsample) |
|
|
|
|
total_matrix, pcd_fix, ply_name = compute_bbox(mesh_obj,obj_name,is_downsample) |
|
|
|
|
|
|
|
|
|
dict_total_matrix[obj_name] = total_matrix |
|
|
|
|
dict_pcd_fix[ply_name] = pcd_fix |
|
|
|
|
|
|
|
|
|
print(f"compute_bbox {obj_name} time={time.time()-start_time}") |
|
|
|
|
print(f"compute_bbox {obj_name} pcd_fix={pcd_fix} time={time.time()-start_time}") |
|
|
|
|
|
|
|
|
|
# dict_mesh_obj.clear() |
|
|
|
|
# del dict_mesh_obj |
|
|
|
|
@ -437,7 +437,26 @@ def compute_bbox_all(dict_mesh_obj,is_downsample):
@@ -437,7 +437,26 @@ def compute_bbox_all(dict_mesh_obj,is_downsample):
|
|
|
|
|
|
|
|
|
|
return dict_total_matrix,all_models |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def compute_bbox(mesh_obj, obj_name="", is_downsample=True): |
|
|
|
|
# return compute_bbox_ext(mesh_obj, obj_name, is_downsample) |
|
|
|
|
|
|
|
|
|
mesh_obj_origin = copy.deepcopy(mesh_obj) |
|
|
|
|
total_matrix, z_max, min_bound, max_bound, ply_name = compute_bbox_ext(mesh_obj, obj_name, is_downsample) |
|
|
|
|
|
|
|
|
|
transformed_vertices = mesh_transform_by_matrix(np.asarray(mesh_obj_origin.vertices), total_matrix) |
|
|
|
|
|
|
|
|
|
pcd = o3d.geometry.PointCloud() |
|
|
|
|
pcd.points = o3d.utility.Vector3dVector(transformed_vertices) |
|
|
|
|
if is_downsample: |
|
|
|
|
pcd_downsampled = down_sample(pcd, voxel_size, False) |
|
|
|
|
pcd_fix = pcd_downsampled |
|
|
|
|
else: |
|
|
|
|
pcd_fix = pcd |
|
|
|
|
|
|
|
|
|
return total_matrix, pcd_fix, ply_name |
|
|
|
|
|
|
|
|
|
def compute_bbox_ext(mesh_obj, obj_name="", is_downsample=True): |
|
|
|
|
|
|
|
|
|
total_matrix = np.eye(4) |
|
|
|
|
total_matrix, z_max= get_lowest_position_of_center_ext(mesh_obj, total_matrix) |
|
|
|
|
@ -451,12 +470,13 @@ def compute_bbox(mesh_obj, obj_name="", is_downsample=True):
@@ -451,12 +470,13 @@ def compute_bbox(mesh_obj, obj_name="", is_downsample=True):
|
|
|
|
|
# 将点云摆正和X轴平衡 |
|
|
|
|
obj_transformed_second,total_matrix = arrange_box_correctly(obj_transformed,voxel_size,total_matrix) |
|
|
|
|
|
|
|
|
|
total_matrix, min_bound, max_bound, pcd_fix, ply_name = get_new_bbox(obj_transformed_second,obj_name,voxel_size,is_downsample,total_matrix) |
|
|
|
|
total_matrix, min_bound, max_bound, ply_name, pcd_fix = get_new_bbox(obj_transformed_second,obj_name,voxel_size,is_downsample,total_matrix) |
|
|
|
|
|
|
|
|
|
del obj_transformed |
|
|
|
|
del obj_transformed_second |
|
|
|
|
|
|
|
|
|
return total_matrix, z_max, min_bound, max_bound, pcd_fix, ply_name |
|
|
|
|
# return total_matrix, z_max, min_bound, max_bound, ply_name, pcd_fix |
|
|
|
|
return total_matrix, z_max, min_bound, max_bound, ply_name |
|
|
|
|
|
|
|
|
|
def arrange_box_correctly(obj_transformed, voxel_size,total_matrix): |
|
|
|
|
|
|
|
|
|
@ -570,7 +590,7 @@ def get_new_bbox(obj_transformed_second,obj_name,voxel_size,is_downsample,total_
@@ -570,7 +590,7 @@ def get_new_bbox(obj_transformed_second,obj_name,voxel_size,is_downsample,total_
|
|
|
|
|
else: |
|
|
|
|
ply_name = "" |
|
|
|
|
|
|
|
|
|
return total_matrix, min_bound, max_bound, pcd_fix, ply_name |
|
|
|
|
return total_matrix, min_bound, max_bound, ply_name, pcd_fix |
|
|
|
|
|
|
|
|
|
class Platform: |
|
|
|
|
def __init__(self, width, depth, height): |
|
|
|
|
|