代码优化
This commit is contained in:
1 parent
e821b820b1
commit
afd3e36de8
9 files changed
+29
-18
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -263,16 +263,6 @@ def process_clound_print(data):
|
||||
# 如果不是 JSON,返回原始字符串作为值
|
||||
print("error!")
|
||||
|
||||
print(f"print_ids={print_ids}")
|
||||
|
||||
# print_ids2 = [115988, 118411]
|
||||
|
||||
# api_addr_pre = "https://mp.api.suwa3d.com"
|
||||
# test = True
|
||||
# if test:
|
||||
# api_addr_pre = "http://127.0.0.1:8199"
|
||||
# url = f"{api_addr_pre}/api/printOrder/getInfoByPrintIds?print_ids={print_ids}"
|
||||
|
||||
url = f"https://mp.api.suwa3d.com/api/printOrder/getInfoByPrintIds?print_ids={print_ids}"
|
||||
res = requests.get(url)
|
||||
|
||||
|
||||
+26
-6
@@ -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):
|
||||
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):
|
||||
|
||||
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):
|
||||
# 将点云摆正和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_
|
||||
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):
|
||||
|
||||
@@ -16,6 +16,7 @@ import argparse
|
||||
from config import print_factory_type_dir
|
||||
|
||||
from general import is_use_debug_oss
|
||||
from general import transform_save_o3d
|
||||
|
||||
CameraModel = collections.namedtuple(
|
||||
"CameraModel", ["model_id", "model_name", "num_params"]
|
||||
|
||||
+2
-2
@@ -94,8 +94,8 @@ def load_and_transform_models(base_path, dict_origin, json_name):
|
||||
print(f"已加载并变换: {index} {os.path.basename(obj_path)}")
|
||||
index = index + 1
|
||||
|
||||
#if (index > 100):
|
||||
# break
|
||||
if (index > 80):
|
||||
break
|
||||
|
||||
add_plank = True
|
||||
if add_plank:
|
||||
|
||||
Reference in new issue
Block a user