Browse Source

代码优化

main
hesuicong 2 weeks ago
parent
commit
afd3e36de8
  1. BIN
      __pycache__/compute_print_net.cpython-312.pyc
  2. BIN
      __pycache__/download_print.cpython-312.pyc
  3. BIN
      __pycache__/point_cloud_layout.cpython-312.pyc
  4. BIN
      __pycache__/print_factory_type_setting_obj_run.cpython-312.pyc
  5. BIN
      __pycache__/test_load_json.cpython-312.pyc
  6. 10
      clound_print.py
  7. 32
      compute_print_net.py
  8. 1
      download_print.py
  9. 4
      test_load_json.py

BIN
__pycache__/compute_print_net.cpython-312.pyc

Binary file not shown.

BIN
__pycache__/download_print.cpython-312.pyc

Binary file not shown.

BIN
__pycache__/point_cloud_layout.cpython-312.pyc

Binary file not shown.

BIN
__pycache__/print_factory_type_setting_obj_run.cpython-312.pyc

Binary file not shown.

BIN
__pycache__/test_load_json.cpython-312.pyc

Binary file not shown.

10
clound_print.py

@ -263,16 +263,6 @@ def process_clound_print(data):
# 如果不是 JSON,返回原始字符串作为值 # 如果不是 JSON,返回原始字符串作为值
print("error!") 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}" url = f"https://mp.api.suwa3d.com/api/printOrder/getInfoByPrintIds?print_ids={print_ids}"
res = requests.get(url) res = requests.get(url)

32
compute_print_net.py

@ -23,7 +23,7 @@ compute_bbox_out
""" """
def compute_bbox_out(mesh_obj): def compute_bbox_out(mesh_obj):
return compute_bbox(mesh_obj) return compute_bbox_ext(mesh_obj)
# -------------------------- 结束:获取bbox数据 -------------------------- # -------------------------- 结束:获取bbox数据 --------------------------
@ -423,12 +423,12 @@ def compute_bbox_all(dict_mesh_obj,is_downsample):
obj_name = key obj_name = key
mesh_obj = value 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_total_matrix[obj_name] = total_matrix
dict_pcd_fix[ply_name] = pcd_fix 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() # dict_mesh_obj.clear()
# del dict_mesh_obj # del dict_mesh_obj
@ -437,7 +437,26 @@ def compute_bbox_all(dict_mesh_obj,is_downsample):
return dict_total_matrix,all_models return dict_total_matrix,all_models
def compute_bbox(mesh_obj, obj_name="", is_downsample=True): 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 = np.eye(4)
total_matrix, z_max= get_lowest_position_of_center_ext(mesh_obj, total_matrix) 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轴平衡 # 将点云摆正和X轴平衡
obj_transformed_second,total_matrix = arrange_box_correctly(obj_transformed,voxel_size,total_matrix) 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
del obj_transformed_second 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): 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: else:
ply_name = "" 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: class Platform:
def __init__(self, width, depth, height): def __init__(self, width, depth, height):

1
download_print.py

@ -16,6 +16,7 @@ import argparse
from config import print_factory_type_dir from config import print_factory_type_dir
from general import is_use_debug_oss from general import is_use_debug_oss
from general import transform_save_o3d
CameraModel = collections.namedtuple( CameraModel = collections.namedtuple(
"CameraModel", ["model_id", "model_name", "num_params"] "CameraModel", ["model_id", "model_name", "num_params"]

4
test_load_json.py

@ -94,8 +94,8 @@ def load_and_transform_models(base_path, dict_origin, json_name):
print(f"已加载并变换: {index} {os.path.basename(obj_path)}") print(f"已加载并变换: {index} {os.path.basename(obj_path)}")
index = index + 1 index = index + 1
#if (index > 100): if (index > 80):
# break break
add_plank = True add_plank = True
if add_plank: if add_plank:

Loading…
Cancel
Save