初步完整接口
This commit is contained in:
1 parent
84ff112176
commit
e821b820b1
16 files changed
+23937
-364
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.
Binary file not shown.
Binary file not shown.
+2
-5
@@ -9,7 +9,6 @@ from download_print import BatchModelInfo
|
||||
from print_factory_type_setting_obj_run import print_type_setting_obj
|
||||
|
||||
from config import print_factory_type_dir
|
||||
from config import is_test
|
||||
from general import is_run_local_data
|
||||
|
||||
# 如果没有 DISPLAY,自动启动 Xvfb
|
||||
@@ -162,8 +161,7 @@ def main():
|
||||
sys.exit(0)
|
||||
|
||||
def test_main():
|
||||
# while True:
|
||||
# data= {'machine_print_counts': 150, 'machine_type': 'small_machine', 'pre_batch_id': 9910032, 'print_machine_id': 14, 'print_orders': [{'counts': 1, 'layout_z': 35.62070959151145, 'model_weight': 41.862, 'order_id': 917900, 'pid': 376666, 'print_id': 126318}, {'counts': 1, 'layout_z': 31.380497732946978, 'model_weight': 35.158, 'order_id': 917810, 'pid': 376562, 'print_id': 126413}, {'counts': 1, 'layout_z': 26.136854969886777, 'model_weight': 21.403, 'order_id': 917820, 'pid': 376572, 'print_id': 126414}, {'counts': 1, 'layout_z': 37.967177899738104, 'model_weight': 30.48, 'order_id': 917922, 'pid': 376684, 'print_id': 126415}, {'counts': 1, 'layout_z': 20.368887098446734, 'model_weight': 13.097, 'order_id': 918228, 'pid': 377198, 'print_id': 126417}, {'counts': 1, 'layout_z': 21.4227336927951, 'model_weight': 15.859, 'order_id': 917576, 'pid': 376345, 'print_id': 126769}, {'counts': 1, 'layout_z': 27.539947066784066, 'model_weight': 25.185, 'order_id': 917811, 'pid': 376564, 'print_id': 126875}, {'counts': 1, 'layout_z': 31.692723822970393, 'model_weight': 32.796, 'order_id': 917821, 'pid': 376592, 'print_id': 126876}, {'counts': 1, 'layout_z': 20.20031720146163, 'model_weight': 8.664, 'order_id': 917822, 'pid': 376602, 'print_id': 126877}, {'counts': 1, 'layout_z': 22.41680629925537, 'model_weight': 15.206, 'order_id': 917827, 'pid': 376616, 'print_id': 126878}, {'counts': 1, 'layout_z': 25.443981671314514, 'model_weight': 11.965, 'order_id': 917879, 'pid': 376635, 'print_id': 126879}, {'counts': 1, 'layout_z': 31.09222672704002, 'model_weight': 20.318, 'order_id': 917902, 'pid': 376667, 'print_id': 126882}, {'counts': 1, 'layout_z': 30.3317820592175, 'model_weight': 32.964, 'order_id': 917903, 'pid': 376668, 'print_id': 126884}, {'counts': 1, 'layout_z': 28.69639626624317, 'model_weight': 27.751, 'order_id': 917904, 'pid': 376669, 'print_id': 126885}, {'counts': 1, 'layout_z': 28.043180029163203, 'model_weight': 19.866, 'order_id': 917917, 'pid': 376677, 'print_id': 126886}, {'counts': 1, 'layout_z': 28.58783468947201, 'model_weight': 25.505, 'order_id': 918196, 'pid': 377126, 'print_id': 126888}, {'counts': 1, 'layout_z': 43.55871899466554, 'model_weight': 63.512, 'order_id': 918201, 'pid': 377131, 'print_id': 126890}, {'counts': 1, 'layout_z': 32.52479624889478, 'model_weight': 22.943, 'order_id': 918203, 'pid': 377133, 'print_id': 126891}, {'counts': 1, 'layout_z': 33.21834123013511, 'model_weight': 42.163, 'order_id': 918206, 'pid': 377139, 'print_id': 126892}, {'counts': 1, 'layout_z': 27.81674335447885, 'model_weight': 15.455, 'order_id': 918207, 'pid': 377141, 'print_id': 126893}, {'counts': 1, 'layout_z': 29.78203639784899, 'model_weight': 29.696, 'order_id': 918231, 'pid': 377201, 'print_id': 126894}, {'counts': 1, 'layout_z': 23.66875736859606, 'model_weight': 13.39, 'order_id': 915637, 'pid': 373135, 'print_id': 126895}, {'counts': 1, 'layout_z': 29.00408914521088, 'model_weight': 19.553, 'order_id': 918246, 'pid': 377209, 'print_id': 126897}, {'counts': 1, 'layout_z': 24.44397251338635, 'model_weight': 15.424, 'order_id': 918325, 'pid': 376974, 'print_id': 126899}, {'counts': 1, 'layout_z': 31.755406379699707, 'model_weight': 31.131, 'order_id': 918492, 'pid': 377584, 'print_id': 126900}, {'counts': 1, 'layout_z': 38.03699946264237, 'model_weight': 47.412, 'order_id': 918493, 'pid': 377587, 'print_id': 126901}, {'counts': 1, 'layout_z': 43.52919799223749, 'model_weight': 37.842, 'order_id': 918494, 'pid': 377589, 'print_id': 126902}, {'counts': 1, 'layout_z': 25.906302369108843, 'model_weight': 18.64, 'order_id': 918495, 'pid': 377590, 'print_id': 126903}, {'counts': 1, 'layout_z': 36.02611978829816, 'model_weight': 43.814, 'order_id': 918496, 'pid': 377591, 'print_id': 126904}, {'counts': 1, 'layout_z': 26.020689766262052, 'model_weight': 18.513, 'order_id': 918497, 'pid': 377594, 'print_id': 126905}, {'counts': 1, 'layout_z': 23.988078117370605, 'model_weight': 15.753, 'order_id': 918498, 'pid': 377596, 'print_id': 126906}, {'counts': 1, 'layout_z': 27.457814063914604, 'model_weight': 23.507, 'order_id': 918500, 'pid': 377601, 'print_id': 126908}, {'counts': 1, 'layout_z': 29.306090320672993, 'model_weight': 25.043, 'order_id': 918501, 'pid': 377605, 'print_id': 126909}, {'counts': 1, 'layout_z': 29.070231478924583, 'model_weight': 25.598, 'order_id': 918504, 'pid': 377606, 'print_id': 126910}, {'counts': 1, 'layout_z': 24.314504768436095, 'model_weight': 18.68, 'order_id': 918555, 'pid': 377684, 'print_id': 126911}, {'counts': 1, 'layout_z': 37.52979171030315, 'model_weight': 53.541, 'order_id': 918558, 'pid': 377689, 'print_id': 126913}, {'counts': 1, 'layout_z': 26.530791960490333, 'model_weight': 15.082, 'order_id': 918560, 'pid': 377702, 'print_id': 126915}, {'counts': 1, 'layout_z': 23.604568481445312, 'model_weight': 21.614, 'order_id': 918583, 'pid': 377748, 'print_id': 126917}, {'counts': 1, 'layout_z': 27.865868478825355, 'model_weight': 22.6, 'order_id': 918636, 'pid': 37Line truncated
|
||||
# data= {'machine_print_counts': 150, 'machine_type': 'big_machine', 'pre_batch_id': 9910032, 'print_machine_id': 14, 'print_orders': [{'counts': 1, 'layout_z': 35.62070959151145, 'model_weight': 41.862, 'order_id': 917900, 'pid': 376666, 'print_id': 126318}, {'counts': 1, 'layout_z': 31.380497732946978, 'model_weight': 35.158, 'order_id': 917810, 'pid': 376562, 'print_id': 126413}, {'counts': 1, 'layout_z': 26.136854969886777, 'model_weight': 21.403, 'order_id': 917820, 'pid': 376572, 'print_id': 126414}, {'counts': 1, 'layout_z': 37.967177899738104, 'model_weight': 30.48, 'order_id': 917922, 'pid': 376684, 'print_id': 126415}, {'counts': 1, 'layout_z': 20.368887098446734, 'model_weight': 13.097, 'order_id': 918228, 'pid': 377198, 'print_id': 126417}, {'counts': 1, 'layout_z': 21.4227336927951, 'model_weight': 15.859, 'order_id': 917576, 'pid': 376345, 'print_id': 126769}, {'counts': 1, 'layout_z': 27.539947066784066, 'model_weight': 25.185, 'order_id': 917811, 'pid': 376564, 'print_id': 126875}, {'counts': 1, 'layout_z': 31.692723822970393, 'model_weight': 32.796, 'order_id': 917821, 'pid': 376592, 'print_id': 126876}, {'counts': 1, 'layout_z': 20.20031720146163, 'model_weight': 8.664, 'order_id': 917822, 'pid': 376602, 'print_id': 126877}, {'counts': 1, 'layout_z': 22.41680629925537, 'model_weight': 15.206, 'order_id': 917827, 'pid': 376616, 'print_id': 126878}, {'counts': 1, 'layout_z': 25.443981671314514, 'model_weight': 11.965, 'order_id': 917879, 'pid': 376635, 'print_id': 126879}, {'counts': 1, 'layout_z': 31.09222672704002, 'model_weight': 20.318, 'order_id': 917902, 'pid': 376667, 'print_id': 126882}, {'counts': 1, 'layout_z': 30.3317820592175, 'model_weight': 32.964, 'order_id': 917903, 'pid': 376668, 'print_id': 126884}, {'counts': 1, 'layout_z': 28.69639626624317, 'model_weight': 27.751, 'order_id': 917904, 'pid': 376669, 'print_id': 126885}, {'counts': 1, 'layout_z': 28.043180029163203, 'model_weight': 19.866, 'order_id': 917917, 'pid': 376677, 'print_id': 126886}, {'counts': 1, 'layout_z': 28.58783468947201, 'model_weight': 25.505, 'order_id': 918196, 'pid': 377126, 'print_id': 126888}, {'counts': 1, 'layout_z': 43.55871899466554, 'model_weight': 63.512, 'order_id': 918201, 'pid': 377131, 'print_id': 126890}, {'counts': 1, 'layout_z': 32.52479624889478, 'model_weight': 22.943, 'order_id': 918203, 'pid': 377133, 'print_id': 126891}, {'counts': 1, 'layout_z': 33.21834123013511, 'model_weight': 42.163, 'order_id': 918206, 'pid': 377139, 'print_id': 126892}, {'counts': 1, 'layout_z': 27.81674335447885, 'model_weight': 15.455, 'order_id': 918207, 'pid': 377141, 'print_id': 126893}, {'counts': 1, 'layout_z': 29.78203639784899, 'model_weight': 29.696, 'order_id': 918231, 'pid': 377201, 'print_id': 126894}, {'counts': 1, 'layout_z': 23.66875736859606, 'model_weight': 13.39, 'order_id': 915637, 'pid': 373135, 'print_id': 126895}, {'counts': 1, 'layout_z': 29.00408914521088, 'model_weight': 19.553, 'order_id': 918246, 'pid': 377209, 'print_id': 126897}, {'counts': 1, 'layout_z': 24.44397251338635, 'model_weight': 15.424, 'order_id': 918325, 'pid': 376974, 'print_id': 126899}, {'counts': 1, 'layout_z': 31.755406379699707, 'model_weight': 31.131, 'order_id': 918492, 'pid': 377584, 'print_id': 126900}, {'counts': 1, 'layout_z': 38.03699946264237, 'model_weight': 47.412, 'order_id': 918493, 'pid': 377587, 'print_id': 126901}, {'counts': 1, 'layout_z': 43.52919799223749, 'model_weight': 37.842, 'order_id': 918494, 'pid': 377589, 'print_id': 126902}, {'counts': 1, 'layout_z': 25.906302369108843, 'model_weight': 18.64, 'order_id': 918495, 'pid': 377590, 'print_id': 126903}, {'counts': 1, 'layout_z': 36.02611978829816, 'model_weight': 43.814, 'order_id': 918496, 'pid': 377591, 'print_id': 126904}, {'counts': 1, 'layout_z': 26.020689766262052, 'model_weight': 18.513, 'order_id': 918497, 'pid': 377594, 'print_id': 126905}, {'counts': 1, 'layout_z': 23.988078117370605, 'model_weight': 15.753, 'order_id': 918498, 'pid': 377596, 'print_id': 126906}, {'counts': 1, 'layout_z': 27.457814063914604, 'model_weight': 23.507, 'order_id': 918500, 'pid': 377601, 'print_id': 126908}, {'counts': 1, 'layout_z': 29.306090320672993, 'model_weight': 25.043, 'order_id': 918501, 'pid': 377605, 'print_id': 126909}, {'counts': 1, 'layout_z': 29.070231478924583, 'model_weight': 25.598, 'order_id': 918504, 'pid': 377606, 'print_id': 126910}, {'counts': 1, 'layout_z': 24.314504768436095, 'model_weight': 18.68, 'order_id': 918555, 'pid': 377684, 'print_id': 126911}, {'counts': 1, 'layout_z': 37.52979171030315, 'model_weight': 53.541, 'order_id': 918558, 'pid': 377689, 'print_id': 126913}, {'counts': 1, 'layout_z': 26.530791960490333, 'model_weight': 15.082, 'order_id': 918560, 'pid': 377702, 'print_id': 126915}, {'counts': 1, 'layout_z': 23.604568481445312, 'model_weight': 21.614, 'order_id': 918583, 'pid': 377748, 'print_id': 126917}, {'counts': 1, 'layout_z': 27.865868478825355, 'model_weight': 22.6, 'order_id': 918636, 'pid': 3778Line truncated
|
||||
data= {"machine_print_counts":50, 'machine_type': 'small_machine',"pre_batch_id":991112,"print_machine_id":22,"print_orders":[{"counts":1,"layout_z":3.543965775898459,"model_weight":12.833,"order_id":857420,"pid":268473,"print_id":85240},{"counts":1,"layout_z":7.798861189952786,"model_weight":13.784,"order_id":875986,"pid":305425,"print_id":88136}]}
|
||||
|
||||
process_clound_print(data)
|
||||
@@ -338,9 +336,8 @@ def process_clound_print(data):
|
||||
if __name__ == '__main__':
|
||||
print(f"is_run_local_data={is_run_local_data()}")
|
||||
if is_run_local_data():
|
||||
# if is_test:
|
||||
test_main()
|
||||
else:
|
||||
print(f"is_test={is_test}, run main")
|
||||
print(f"run main")
|
||||
main()
|
||||
|
||||
+44
-20
@@ -6,21 +6,30 @@ import argparse
|
||||
|
||||
from general import *
|
||||
|
||||
# -------------------------- 开始:获取z值最低 --------------------------
|
||||
# -------------------------- 开始:获取bbox数据 -------------------------
|
||||
|
||||
"""
|
||||
对外部提供的获取最低z的接口
|
||||
get_lowest_position_of_z_out
|
||||
对外部提供的获取bbox数据的接口
|
||||
compute_bbox_out
|
||||
|
||||
参数:
|
||||
obj_path, 模型数据路径
|
||||
|
||||
返回:
|
||||
total_matrix: 旋转矩阵
|
||||
z_max: Z最高点
|
||||
z_max: z最高点
|
||||
min_bound:bbox最低点, 例如[-1.0, -1.0, 0.0]
|
||||
max_bound:bbox最低点, 例如[0.0, 0.0, 1.0]
|
||||
"""
|
||||
|
||||
def get_lowest_position_of_z_out(mesh_obj):
|
||||
def compute_bbox_out(mesh_obj):
|
||||
return compute_bbox(mesh_obj)
|
||||
|
||||
# -------------------------- 结束:获取bbox数据 --------------------------
|
||||
|
||||
# -------------------------- 开始:获取z值最低 --------------------------
|
||||
|
||||
def get_lowest_position_of_z_ext(mesh_obj):
|
||||
|
||||
total_matrix = np.eye(4)
|
||||
|
||||
@@ -222,7 +231,7 @@ def get_lowest_position_of_z_out(mesh_obj):
|
||||
|
||||
# print(f"z_mean1={z_mean1}, z_mean2={z_mean2}")
|
||||
# if (z_mean2 > z_mean1):
|
||||
print(f"z_volume_center1={z_volume_center1}, z_volume_center2={z_volume_center2}")
|
||||
# print(f"z_volume_center1={z_volume_center1}, z_volume_center2={z_volume_center2}")
|
||||
if (z_volume_center2 > z_volume_center1):
|
||||
R_y = pcd_transformed.get_rotation_matrix_from_axis_angle(np.array([0, 1, 0]) * -angle_rad)
|
||||
centroid = pcd_transformed.get_center()
|
||||
@@ -265,8 +274,8 @@ def get_lowest_position_of_z_out(mesh_obj):
|
||||
return total_matrix, z_max
|
||||
|
||||
def get_lowest_position_of_center_ext(mesh_obj, total_matrix):
|
||||
# print(f"get_lowest_position_of_center_ext {obj_path}")
|
||||
temp_matrix, z_max = get_lowest_position_of_z_out(mesh_obj)
|
||||
print(f"get_lowest_position_of_center_ext mesh_obj={mesh_obj}")
|
||||
temp_matrix, z_max = get_lowest_position_of_z_ext(mesh_obj)
|
||||
|
||||
total_matrix = temp_matrix @ total_matrix
|
||||
|
||||
@@ -405,7 +414,7 @@ def compute_bbox_all_ext(base_original_obj_dir,compact_min_dis=True):
|
||||
|
||||
return compute_bbox_all(dict_mesh_obj,compact_min_dis)
|
||||
|
||||
def compute_bbox_all(dict_mesh_obj,compact_min_dis):
|
||||
def compute_bbox_all(dict_mesh_obj,is_downsample):
|
||||
dict_total_matrix= {}
|
||||
dict_pcd_fix= {}
|
||||
for key, value in dict_mesh_obj.items():
|
||||
@@ -414,21 +423,24 @@ def compute_bbox_all(dict_mesh_obj,compact_min_dis):
|
||||
obj_name = key
|
||||
mesh_obj = value
|
||||
|
||||
total_matrix, pcd_fix, ply_name = compute_bbox(mesh_obj,obj_name,compact_min_dis)
|
||||
total_matrix, min_bound, max_bound, 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}")
|
||||
|
||||
# dict_mesh_obj.clear()
|
||||
# del dict_mesh_obj
|
||||
|
||||
all_models = get_models_bbox(dict_pcd_fix)
|
||||
|
||||
return dict_total_matrix,all_models
|
||||
|
||||
def compute_bbox(mesh_obj,obj_name,compact_min_dis):
|
||||
def compute_bbox(mesh_obj, obj_name="", is_downsample=True):
|
||||
|
||||
total_matrix = np.eye(4)
|
||||
total_matrix, z_min= get_lowest_position_of_center_ext(mesh_obj, total_matrix)
|
||||
total_matrix, z_max= get_lowest_position_of_center_ext(mesh_obj, total_matrix)
|
||||
|
||||
transformed_vertices = mesh_transform_by_matrix(np.asarray(mesh_obj.vertices), total_matrix)
|
||||
|
||||
@@ -439,9 +451,12 @@ def compute_bbox(mesh_obj,obj_name,compact_min_dis):
|
||||
# 将点云摆正和X轴平衡
|
||||
obj_transformed_second,total_matrix = arrange_box_correctly(obj_transformed,voxel_size,total_matrix)
|
||||
|
||||
obj_transformed,total_matrix,pcd_fix,ply_name = get_new_bbox(obj_transformed_second,obj_name,voxel_size,compact_min_dis,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)
|
||||
|
||||
return total_matrix,pcd_fix,ply_name
|
||||
del obj_transformed
|
||||
del obj_transformed_second
|
||||
|
||||
return total_matrix, z_max, min_bound, max_bound, pcd_fix, ply_name
|
||||
|
||||
def arrange_box_correctly(obj_transformed, voxel_size,total_matrix):
|
||||
|
||||
@@ -491,7 +506,7 @@ def arrange_box_correctly(obj_transformed, voxel_size,total_matrix):
|
||||
|
||||
return obj_transformed, total_matrix
|
||||
|
||||
def get_new_bbox(obj_transformed_second,obj_name,voxel_size,compact_min_dis,total_matrix):
|
||||
def get_new_bbox(obj_transformed_second,obj_name,voxel_size,is_downsample,total_matrix):
|
||||
|
||||
# 计算点云的边界
|
||||
points = np.asarray(obj_transformed_second.vertices)
|
||||
@@ -499,6 +514,8 @@ def get_new_bbox(obj_transformed_second,obj_name,voxel_size,compact_min_dis,tota
|
||||
min_bound = np.min(points, axis=0) # 获取点云的最小边界
|
||||
max_bound = np.max(points, axis=0) # 获取点云的最大边界
|
||||
|
||||
# print(f"get_new_bbox1: min_bound={min_bound}, max_bound={max_bound}")
|
||||
|
||||
# 确保包围盒的Y坐标不低于0
|
||||
min_bound[2] = max(min_bound[2], 0) # 确保Y坐标的最小值不低于0
|
||||
|
||||
@@ -537,16 +554,23 @@ def get_new_bbox(obj_transformed_second,obj_name,voxel_size,compact_min_dis,tota
|
||||
vertices = np.asarray(obj_transformed_second.vertices)
|
||||
pcd = o3d.geometry.PointCloud()
|
||||
pcd.points = o3d.utility.Vector3dVector(vertices)
|
||||
if compact_min_dis:
|
||||
if is_downsample:
|
||||
pcd_downsampled = down_sample(pcd, voxel_size, False)
|
||||
pcd_fix = pcd_downsampled
|
||||
else:
|
||||
pcd_fix = pcd
|
||||
|
||||
ply_print_pid = obj_name.replace(".obj","")
|
||||
ply_name = f"{ply_print_pid}={z_length}+{y_length}+{x_length}.ply"
|
||||
min_bound = np.min(pcd.points, axis=0) # 获取点云的最小边界
|
||||
max_bound = np.max(pcd.points, axis=0) # 获取点云的最大边界
|
||||
# print(f"get_new_bbox2: min_bound={min_bound}, max_bound={max_bound}")
|
||||
|
||||
return obj_transformed_second, total_matrix, pcd_fix, ply_name
|
||||
if (not obj_name == ""):
|
||||
ply_print_pid = obj_name.replace(".obj","")
|
||||
ply_name = f"{ply_print_pid}={z_length}+{y_length}+{x_length}.ply"
|
||||
else:
|
||||
ply_name = ""
|
||||
|
||||
return total_matrix, min_bound, max_bound, pcd_fix, ply_name
|
||||
|
||||
class Platform:
|
||||
def __init__(self, width, depth, height):
|
||||
@@ -744,5 +768,5 @@ if __name__ == '__main__':
|
||||
args = parser.parse_args()
|
||||
|
||||
obj_path = args.obj_path
|
||||
max, z = get_lowest_position_of_z_out(obj_path)
|
||||
max, z = get_lowest_position_of_z_ext(obj_path)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
|
||||
# -------------------------- 开始:运行模式 -------------------------------
|
||||
from enum import Enum
|
||||
class run_mode(Enum):
|
||||
formal = 1
|
||||
@@ -6,13 +8,17 @@ class run_mode(Enum):
|
||||
|
||||
# !!!谨慎选择run_mode.fix,这将把修复的数据上传到正式的系统 !!!
|
||||
curr_run_mode = run_mode.test
|
||||
# -------------------------- 结束:运行模式 -------------------------------
|
||||
|
||||
is_test = True
|
||||
|
||||
# -------------------------- 开始:路径配置 -------------------------------
|
||||
# print_factory_type_dir="/root/print_factory_type"
|
||||
print_factory_type_dir="/home/algo/Documents/print_factory_type"
|
||||
|
||||
url_send_layout = 'https://mp.api.suwa3d.com/api/printTypeSettingOrder/printTypeSettingOrderSuccess'
|
||||
# -------------------------- 结束:路径配置 -------------------------------
|
||||
|
||||
|
||||
# -------------------------- 开始:机台尺寸 -------------------------------
|
||||
big_machine_size = [600, 500, 300]
|
||||
small_machine_size = [380, 345, 250]
|
||||
# -------------------------- 结束:机台尺寸 -------------------------------
|
||||
+8
-6
@@ -14,7 +14,6 @@ import os
|
||||
import argparse
|
||||
|
||||
from config import print_factory_type_dir
|
||||
from config import is_test
|
||||
|
||||
from general import is_use_debug_oss
|
||||
|
||||
@@ -1043,6 +1042,7 @@ class DataTransfer:
|
||||
prefix_exists = True
|
||||
if obj.key != prefix: # 跳过目录本身
|
||||
objects.append(obj.key)
|
||||
print(f"obj.key={obj.key}")
|
||||
|
||||
if not prefix_exists:
|
||||
print(f"前缀 '{prefix}' 下没有找到任何文件或目录。")
|
||||
@@ -1109,6 +1109,7 @@ class DataTransfer:
|
||||
new_mtl_name = f"{batch_model_info.order_id}_{old_mtl_name}"
|
||||
f_out.write(f"mtllib {new_mtl_name}\n")
|
||||
mtllib_modified = True
|
||||
print("len(parts) > 1")
|
||||
continue
|
||||
f_out.write(line)
|
||||
|
||||
@@ -1361,13 +1362,14 @@ def download_data_by_batch(batch_model_info, workdir, oss_client ):
|
||||
download_textures = DataTransfer(target_dir, f"{path}/", oss_client)
|
||||
|
||||
if not download_textures.download_data_rename_batch(batch_model_info):
|
||||
print("fail download_data_rename_batch")
|
||||
return False
|
||||
# 下载后检查目标文件夹是否为空
|
||||
if os.path.exists(target_dir) and not os.listdir(target_dir):
|
||||
shutil.rmtree(target_dir)
|
||||
print(f"下载后检查发现目标文件夹为空,已删除: {target_dir}")
|
||||
except Exception as e:
|
||||
print(f"卡通图片下载失败: {path}, 错误: {str(e)}")
|
||||
print(f"下载失败: {path}, 错误: {str(e)}")
|
||||
pass
|
||||
|
||||
return True
|
||||
@@ -1381,9 +1383,10 @@ def download_datas_by_batch(batch_id, workdir, oss_config):
|
||||
# 批量下载
|
||||
for batch_model_info in list_print_model_info:
|
||||
print(f"开始下载print_model_info: {batch_model_info}")
|
||||
download_data_by_batch(batch_model_info, workdir, oss_client)
|
||||
if not download_data_by_batch(batch_model_info, workdir, oss_client):
|
||||
return datas, False
|
||||
|
||||
return datas
|
||||
return datas, True
|
||||
|
||||
def download_datas_by_pre_layout(list_print_model_info, workdir, oss_config):
|
||||
oss_client = get_oss_client(oss_config)
|
||||
@@ -1397,7 +1400,7 @@ def download_datas_by_pre_layout(list_print_model_info, workdir, oss_config):
|
||||
return True
|
||||
|
||||
def download_transform_save_by_batch(batch_id, workdir, oss_config):
|
||||
datas = download_datas_by_batch(batch_id, workdir, oss_config)
|
||||
datas, succ = download_datas_by_batch(batch_id, workdir, oss_config)
|
||||
print("datas=", datas)
|
||||
layout_data = datas["layout_data"]
|
||||
|
||||
@@ -1439,7 +1442,6 @@ def upload_result(base_original_obj_dir, oss_config, batch_id):
|
||||
oss_batch_dir = "batchPrint"
|
||||
print(f"is_use_debug_oss={is_use_debug_oss()}")
|
||||
if is_use_debug_oss():
|
||||
# if is_test:
|
||||
oss_batch_dir = "batchPrint/debug_hsc"
|
||||
|
||||
print(f"target_dir={target_dir}, batch_id={batch_id}")
|
||||
|
||||
+13
-3
@@ -24,8 +24,8 @@ def is_use_debug_oss():
|
||||
|
||||
# -------------------------- 开始:模型 ----------------------------------
|
||||
|
||||
def read_mesh(obj_path):
|
||||
mesh_obj = o3d.io.read_triangle_mesh(obj_path)
|
||||
def read_mesh(obj_path, enable_post_processing=False):
|
||||
mesh_obj = o3d.io.read_triangle_mesh(obj_path, enable_post_processing)
|
||||
return mesh_obj
|
||||
|
||||
def down_sample(pcd, voxel_size, farthest_sample = False):
|
||||
@@ -119,6 +119,10 @@ def mesh_transform_by_matrix(vertices, transform_matrix):
|
||||
|
||||
# 3. 转回非齐次坐标 (3xN) → (N, 3)
|
||||
transformed_vertices = transformed_homogeneous[:3, :].T
|
||||
|
||||
del homogeneous_vertices
|
||||
del transformed_homogeneous
|
||||
|
||||
return transformed_vertices
|
||||
|
||||
import os
|
||||
@@ -207,7 +211,7 @@ def transform_save_o3d(layout_data, original_obj_pid_dir):
|
||||
obj_path = os.path.join(original_obj_pid_dir, obj_name)
|
||||
# 加载网格
|
||||
try:
|
||||
mesh = o3d.io.read_triangle_mesh(obj_path, enable_post_processing=True)
|
||||
mesh = read_mesh(obj_path, enable_post_processing=True)
|
||||
if not mesh.has_vertices():
|
||||
print(f"警告: 网格无有效顶点 - {obj_path}")
|
||||
continue
|
||||
@@ -261,6 +265,12 @@ def is_same_obj(obj_name1, obj_name2):
|
||||
|
||||
return False
|
||||
|
||||
def get_blank_path(is_small_machine=False):
|
||||
if is_small_machine:
|
||||
return os.path.join(print_factory_type_dir, "blank/blank_bias/blank_small.obj")
|
||||
else:
|
||||
return os.path.join(print_factory_type_dir, "blank/blank_bias/blank2.obj")
|
||||
|
||||
# -------------------------- 结束:模型 ----------------------------------
|
||||
|
||||
# -------------------------- 开始:碰撞检测和越界 --------------------------
|
||||
|
||||
+23759
-237
File diff suppressed because it is too large.
Load diff
+18
-17
@@ -9,21 +9,20 @@ import open3d as o3d
|
||||
import numpy as np
|
||||
from plyfile import PlyData, PlyElement
|
||||
|
||||
from config import is_test
|
||||
from config import print_factory_type_dir
|
||||
|
||||
from general import mesh_tranform_to_pcd
|
||||
from general import need_upload_result
|
||||
from general import read_mesh
|
||||
|
||||
from compute_print_net import get_models_bbox
|
||||
from compute_print_net import arrange_models_on_platform
|
||||
from compute_print_net import Platform
|
||||
from compute_print_net import down_sample
|
||||
from compute_print_net import read_mesh
|
||||
from compute_print_net import compute_bbox_all
|
||||
from compute_print_net import compute_bbox_all_ext
|
||||
|
||||
def make_bbox_for_print(base_original_obj_dir,dict_bad,dict_origin,compact_min_dis):
|
||||
def make_bbox_for_print(base_original_obj_dir,dict_bad,dict_origin,is_downsample):
|
||||
"""获取需要的盒子大小"""
|
||||
start_time = time.time()
|
||||
|
||||
@@ -31,8 +30,10 @@ def make_bbox_for_print(base_original_obj_dir,dict_bad,dict_origin,compact_min_d
|
||||
obj_id_list = obj_id_list
|
||||
|
||||
dict_mesh_obj = {}
|
||||
index = 0
|
||||
for pid_t_y in obj_id_list:
|
||||
|
||||
start_time1 = time.time()
|
||||
obj_name = pid_t_y+".obj"
|
||||
obj_path = os.path.join(base_original_obj_dir,obj_name)
|
||||
mesh_obj = read_mesh(obj_path)
|
||||
@@ -46,14 +47,17 @@ def make_bbox_for_print(base_original_obj_dir,dict_bad,dict_origin,compact_min_d
|
||||
print(f"Skipping invalid file: {obj_path}")
|
||||
continue
|
||||
|
||||
# dict_origin[obj_path] = copy.deepcopy(mesh_obj)
|
||||
dict_origin[obj_name] = copy.deepcopy(mesh_obj)
|
||||
dict_origin[obj_name] = mesh_obj
|
||||
dict_mesh_obj[obj_name] = mesh_obj
|
||||
|
||||
print(f"make_bbox_for_print {index} {obj_name} time={time.time()-start_time1}")
|
||||
|
||||
index = index + 1
|
||||
|
||||
print(f"make_bbox_for_print total_time={time.time()-start_time}")
|
||||
|
||||
dict_total_matrix,all_models = compute_bbox_all_ext(base_original_obj_dir, compact_min_dis)
|
||||
# dict_total_matrix,all_models = compute_bbox_all(dict_mesh_obj, compact_min_dis)
|
||||
# dict_total_matrix,all_models = compute_bbox_all_ext(base_original_obj_dir, is_downsample)
|
||||
dict_total_matrix,all_models = compute_bbox_all(dict_mesh_obj, is_downsample)
|
||||
return get_dict_pcd(dict_mesh_obj,dict_total_matrix,all_models)
|
||||
|
||||
def get_dict_pcd(dict_mesh_obj,dict_total_matrix,all_models):
|
||||
@@ -78,6 +82,9 @@ def get_pcd_by_matrix(dict_mesh_obj,dict_total_matrix,dict_ply_name):
|
||||
pcd_fix = mesh_tranform_to_pcd(mesh_obj, dict_total_matrix[obj_name])
|
||||
dict_pcd_fix[dict_ply_name[obj_name]] = pcd_fix
|
||||
|
||||
dict_mesh_obj.clear()
|
||||
del dict_mesh_obj
|
||||
|
||||
return dict_pcd_fix
|
||||
|
||||
|
||||
@@ -1327,14 +1334,8 @@ def move_obj_to_compact_bounds_json(base_original_obj_dir,dict_mesh_obj,dict_unp
|
||||
"type_setting_start_time": print_start_time
|
||||
}
|
||||
|
||||
print("is_test=", is_test)
|
||||
print(f"need_upload_result={need_upload_result()}")
|
||||
# if need_upload_result():
|
||||
if is_test:
|
||||
is_send_layout_data = False
|
||||
else:
|
||||
is_send_layout_data = True
|
||||
# is_send_layout_data = False
|
||||
is_need_upload_result = need_upload_result()
|
||||
|
||||
obj_file_list = list(dict_mesh_obj.keys())
|
||||
ply_path_dict = {}
|
||||
@@ -1350,12 +1351,12 @@ def move_obj_to_compact_bounds_json(base_original_obj_dir,dict_mesh_obj,dict_unp
|
||||
ply_name_pid = obj_name.replace(".obj", "")
|
||||
ply_name = ply_path_dict.get(ply_name_pid, None)
|
||||
|
||||
if is_send_layout_data:
|
||||
if is_need_upload_result:
|
||||
result = extract_numbers_from_filename(ply_name)
|
||||
|
||||
if not ply_name or ply_name in dict_unplaced:
|
||||
|
||||
if is_send_layout_data:
|
||||
if is_need_upload_result:
|
||||
print_id = result[2]
|
||||
order_id = result[0]
|
||||
status = 0
|
||||
@@ -1388,7 +1389,7 @@ def move_obj_to_compact_bounds_json(base_original_obj_dir,dict_mesh_obj,dict_unp
|
||||
}
|
||||
})
|
||||
|
||||
if is_send_layout_data:
|
||||
if is_need_upload_result:
|
||||
print_id = result[2]
|
||||
order_id = result[0]
|
||||
status = 1
|
||||
|
||||
@@ -13,12 +13,12 @@ from test_load_json import load_show_save
|
||||
from download_print import upload_result
|
||||
|
||||
from config import print_factory_type_dir
|
||||
from config import is_test
|
||||
from config import url_send_layout
|
||||
from config import big_machine_size
|
||||
from config import small_machine_size
|
||||
|
||||
from general import need_upload_result
|
||||
from general import get_blank_path
|
||||
|
||||
from point_cloud_layout import make_bbox_for_print
|
||||
|
||||
@@ -66,7 +66,8 @@ def print_type_setting_obj(base_original_obj_dir=None,batch_id=0,selected_mode="
|
||||
dict_bad = {}
|
||||
dict_origin = {}
|
||||
|
||||
dict_total_matrix, all_models, dict_pcd_fix = make_bbox_for_print(base_original_obj_dir,dict_bad,dict_origin,compact_min_dis)
|
||||
is_downsample = compact_min_dis
|
||||
dict_total_matrix, all_models, dict_pcd_fix = make_bbox_for_print(base_original_obj_dir,dict_bad,dict_origin,is_downsample)
|
||||
mesh_count = len(dict_origin)
|
||||
if mesh_count<=0:
|
||||
print("选择的文件夹没有模型")
|
||||
@@ -131,8 +132,7 @@ def print_type_setting_obj(base_original_obj_dir=None,batch_id=0,selected_mode="
|
||||
is_screenshot = True
|
||||
if is_screenshot:
|
||||
start_time = time.time()
|
||||
blank_path = get_blank_path(is_small_machine)
|
||||
load_show_save(base_original_obj_dir, dict_origin, blank_path, batch_id)
|
||||
load_show_save(base_original_obj_dir, dict_origin, batch_id)
|
||||
elapsed_seconds5 = time.time() - start_time
|
||||
elapsed_minutes5 = int(elapsed_seconds5 // 60)
|
||||
print(f"保存截图耗时::{elapsed_minutes5} 分 / {elapsed_seconds5} 秒")
|
||||
@@ -149,15 +149,8 @@ def print_type_setting_obj(base_original_obj_dir=None,batch_id=0,selected_mode="
|
||||
|
||||
upload_result(base_original_obj_dir, oss_config, batch_id)
|
||||
|
||||
print(f"is_test={is_test}")
|
||||
print(f"need_upload_result={need_upload_result()}")
|
||||
# if need_upload_result():
|
||||
if is_test :
|
||||
is_send_layout_data = False
|
||||
else :
|
||||
is_send_layout_data = True
|
||||
|
||||
if is_send_layout_data:
|
||||
if need_upload_result():
|
||||
print(f"send_layout_data={send_layout_data}")
|
||||
# url = 'https://mp.api.suwa3d.com/api/printTypeSettingOrder/printTypeSettingOrderSuccess'
|
||||
url = url_send_layout
|
||||
@@ -188,20 +181,9 @@ def print_type_setting_obj(base_original_obj_dir=None,batch_id=0,selected_mode="
|
||||
|
||||
return 0
|
||||
|
||||
def get_blank_path(is_small_machine=False):
|
||||
if is_small_machine:
|
||||
return os.path.join(print_factory_type_dir, "blank/blank_bias/blank_small.obj")
|
||||
else:
|
||||
return os.path.join(print_factory_type_dir, "blank/blank_bias/blank2.obj")
|
||||
def preview(base_original_obj_dir=None, batch_id=0):
|
||||
|
||||
def preview(base_original_obj_dir=None, batch_id=0, is_small_machine=False):
|
||||
|
||||
base_path = get_base_directory()
|
||||
parent_dir = os.path.dirname(base_path)
|
||||
# blank_dir = os.path.join(parent_dir, "blank", "blank_bias")
|
||||
blank_path = get_blank_path(is_small_machine)
|
||||
|
||||
load_show_save(base_original_obj_dir, {}, blank_path, batch_id, True)
|
||||
load_show_save(base_original_obj_dir, {}, batch_id, True)
|
||||
|
||||
def get_pcd(obj, is_down_sample=True):
|
||||
vertices = np.asarray(obj.vertices)
|
||||
@@ -221,7 +203,7 @@ if __name__ == '__main__':
|
||||
# args = parser.parse_args()
|
||||
|
||||
# batch_id = args.batch_id
|
||||
batch_id = "1"
|
||||
batch_id = "9910032"
|
||||
src_dir = batch_id
|
||||
selected_mode="紧凑" # 标准 紧凑
|
||||
output_format="JSON" # 模型 JSON
|
||||
|
||||
+77
-48
@@ -4,11 +4,14 @@ import json
|
||||
import os
|
||||
from PIL import Image
|
||||
import argparse
|
||||
import gc
|
||||
|
||||
from config import print_factory_type_dir
|
||||
from general import mesh_transform_by_matrix
|
||||
from general import read_mesh
|
||||
from general import get_blank_path
|
||||
|
||||
def load_and_transform_models(base_path, dict_origin, blank_path, json_name):
|
||||
def load_and_transform_models(base_path, dict_origin, json_name):
|
||||
|
||||
meshes = [] # 存储所有变换后的网格
|
||||
|
||||
@@ -30,8 +33,13 @@ def load_and_transform_models(base_path, dict_origin, blank_path, json_name):
|
||||
print(f"读取JSON文件失败: {e}")
|
||||
return []
|
||||
|
||||
print(f"选择机型={data.get('summary')['selected_machine']}")
|
||||
selected_machine = data.get('summary')['selected_machine']
|
||||
print(f"选择机型={selected_machine}")
|
||||
|
||||
is_small_machine = True if selected_machine=="小机型" else False
|
||||
blank_path = get_blank_path(is_small_machine)
|
||||
|
||||
index = 0
|
||||
# 处理每个模型
|
||||
for model in data.get('models', []):
|
||||
obj_name = model.get('file_name', '')
|
||||
@@ -54,11 +62,11 @@ def load_and_transform_models(base_path, dict_origin, blank_path, json_name):
|
||||
key = obj_path
|
||||
if key in dict_origin:
|
||||
# print("key in dict_origin")
|
||||
mesh = dict_origin[key]
|
||||
mesh_obj = dict_origin[key]
|
||||
else :
|
||||
# print("key not in dict_origin")
|
||||
mesh = o3d.io.read_triangle_mesh(obj_path, enable_post_processing=True)
|
||||
if not mesh.has_vertices():
|
||||
mesh_obj = read_mesh(obj_path,True)
|
||||
if not mesh_obj.has_vertices():
|
||||
print(f"警告: 网格无有效顶点 - {obj_path}")
|
||||
continue
|
||||
except Exception as e:
|
||||
@@ -71,22 +79,31 @@ def load_and_transform_models(base_path, dict_origin, blank_path, json_name):
|
||||
reconstructed_matrix = np.array(homo_matrix, dtype=np.float64)
|
||||
|
||||
# 手动变换顶点
|
||||
original_vertices = np.asarray(mesh.vertices)
|
||||
original_vertices = np.asarray(mesh_obj.vertices)
|
||||
transformed_vertices = mesh_transform_by_matrix(original_vertices, reconstructed_matrix)
|
||||
mesh.vertices = o3d.utility.Vector3dVector(transformed_vertices)
|
||||
mesh_obj.vertices = o3d.utility.Vector3dVector(transformed_vertices)
|
||||
|
||||
del original_vertices, transformed_vertices, reconstructed_matrix
|
||||
|
||||
# 添加到列表
|
||||
meshes.append(mesh)
|
||||
print(f"已加载并变换: {os.path.basename(obj_path)}")
|
||||
meshes.append(mesh_obj)
|
||||
del mesh_obj
|
||||
|
||||
gc.collect()
|
||||
|
||||
print(f"已加载并变换: {index} {os.path.basename(obj_path)}")
|
||||
index = index + 1
|
||||
|
||||
#if (index > 100):
|
||||
# break
|
||||
|
||||
add_plank = True
|
||||
if add_plank:
|
||||
# obj_path = os.path.join(blank_dir, "blank2.obj")
|
||||
obj_path = blank_path
|
||||
print("add_plank",obj_path)
|
||||
|
||||
try:
|
||||
mesh = o3d.io.read_triangle_mesh(obj_path, enable_post_processing=True)
|
||||
mesh = read_mesh(obj_path, True)
|
||||
if not mesh.has_vertices():
|
||||
print(f"警告: 网格无有效顶点 - {obj_path}")
|
||||
except Exception as e:
|
||||
@@ -130,9 +147,9 @@ def compute_mesh_center(vertices):
|
||||
centroid = np.array([sum_x / n, sum_y / n, sum_z / n])
|
||||
return centroid
|
||||
|
||||
def load_and_show(base_path, blank_dir, json_name="3DPrintLayout.json"):
|
||||
def load_and_show(base_path, json_name="3DPrintLayout.json"):
|
||||
# 加载并变换所有模型
|
||||
transformed_meshes = load_and_transform_models(base_path, {}, blank_dir, json_name)
|
||||
transformed_meshes = load_and_transform_models(base_path, {}, json_name)
|
||||
|
||||
if not transformed_meshes:
|
||||
print("没有加载到任何模型,请检查错误信息")
|
||||
@@ -305,30 +322,26 @@ def set_orthographic_projection(view_control, ortho_scale=10.0):
|
||||
print(f"在配置 ViewControl 参数时出错: {e}")
|
||||
return False
|
||||
|
||||
def set_orthographic(meshes, output_path, width=1920, height=1080,
|
||||
def set_orthographic(meshes, width=1920, height=1080,
|
||||
background_color=[1, 1, 1], camera_position=None,
|
||||
ortho_width=None, zoom=1.0):
|
||||
|
||||
vis = o3d.visualization.Visualizer()
|
||||
vis.create_window(width=width, height=height, visible=False)
|
||||
|
||||
# 添加几何体
|
||||
for mesh in meshes:
|
||||
vis.add_geometry(mesh)
|
||||
|
||||
|
||||
# 设置渲染选项
|
||||
render_opt = vis.get_render_option()
|
||||
render_opt.background_color = np.asarray(background_color)
|
||||
render_opt.mesh_show_back_face = True
|
||||
render_opt.mesh_show_wireframe = False
|
||||
render_opt.point_size = 3.0
|
||||
|
||||
# 视角控制
|
||||
view_control = vis.get_view_control()
|
||||
|
||||
# 计算所有网格的合并边界框,用于自适应设置投影参数
|
||||
|
||||
all_points = []
|
||||
index = 0
|
||||
# 添加几何体
|
||||
for mesh in meshes:
|
||||
vis.add_geometry(mesh)
|
||||
|
||||
if hasattr(mesh, 'vertices'):
|
||||
points = np.asarray(mesh.vertices)
|
||||
elif hasattr(mesh, 'points'):
|
||||
@@ -337,11 +350,25 @@ def set_orthographic(meshes, output_path, width=1920, height=1080,
|
||||
continue
|
||||
if len(points) > 0:
|
||||
all_points.append(points)
|
||||
|
||||
del mesh
|
||||
del points
|
||||
gc.collect()
|
||||
print(f"set_orthographic {index}")
|
||||
index = index + 1
|
||||
|
||||
del meshes
|
||||
gc.collect()
|
||||
|
||||
# 视角控制
|
||||
view_control = vis.get_view_control()
|
||||
|
||||
if len(all_points) > 0:
|
||||
all_points = np.vstack(all_points)
|
||||
bbox_min = np.min(all_points, axis=0)
|
||||
bbox_max = np.max(all_points, axis=0)
|
||||
all_points_v = np.vstack(all_points)
|
||||
del all_points
|
||||
gc.collect()
|
||||
bbox_min = np.min(all_points_v, axis=0)
|
||||
bbox_max = np.max(all_points_v, axis=0)
|
||||
bbox_center = (bbox_min + bbox_max) / 2.0
|
||||
bbox_size = np.max(bbox_max - bbox_min)
|
||||
|
||||
@@ -365,6 +392,9 @@ def set_orthographic(meshes, output_path, width=1920, height=1080,
|
||||
ortho_width *= aspect_ratio
|
||||
if ortho_width <= 0:
|
||||
ortho_width = 10.0
|
||||
|
||||
del all_points_v
|
||||
gc.collect()
|
||||
else:
|
||||
# 如果没有顶点,使用默认值
|
||||
if not camera_position:
|
||||
@@ -373,37 +403,39 @@ def set_orthographic(meshes, output_path, width=1920, height=1080,
|
||||
view_control.set_up([0, 1, 0])
|
||||
ortho_width = ortho_width or 10.0
|
||||
|
||||
for _ in range(2):
|
||||
vis.poll_events()
|
||||
vis.update_renderer()
|
||||
print("set_orthographic 1")
|
||||
#for _ in range(2):
|
||||
# vis.poll_events()
|
||||
# vis.update_renderer()
|
||||
|
||||
# 设置正交投影
|
||||
try:
|
||||
set_orthographic_camera(view_control)
|
||||
print("set_orthographic 2")
|
||||
except AttributeError:
|
||||
set_orthographic_projection(view_control, ortho_scale=15.0)
|
||||
print("set_orthographic 3")
|
||||
|
||||
for _ in range(5):
|
||||
vis.poll_events()
|
||||
vis.update_renderer()
|
||||
#for _ in range(5):
|
||||
# vis.poll_events()
|
||||
# vis.update_renderer()
|
||||
|
||||
print("set_orthographic End")
|
||||
|
||||
return vis
|
||||
|
||||
def render_to_texture(meshes, output_path, width=1920, height=1080,
|
||||
background_color=[1, 1, 1], camera_position=None,
|
||||
ortho_width=None, zoom=1.0):
|
||||
def render_to_texture(meshes, output_image_path):
|
||||
|
||||
|
||||
vis = set_orthographic(meshes, output_path)
|
||||
vis = set_orthographic(meshes)
|
||||
|
||||
# 渲染并保存
|
||||
vis.capture_screen_image(output_path, do_render=True)
|
||||
vis.capture_screen_image(output_image_path, do_render=True)
|
||||
|
||||
print(f"高级渲染图片已保存到: {output_path}")
|
||||
print(f"高级渲染图片已保存到: {output_image_path}")
|
||||
|
||||
return vis
|
||||
|
||||
def load_show_save(base_path, dict_origin, blank_path, batch_id, is_show=False):
|
||||
def load_show_save(base_path, dict_origin, batch_id, is_show=False):
|
||||
|
||||
folder_name = batch_id
|
||||
|
||||
@@ -413,14 +445,14 @@ def load_show_save(base_path, dict_origin, blank_path, batch_id, is_show=False):
|
||||
output_image_path = os.path.join(base_path, f"{folder_name}.jpg")
|
||||
|
||||
# 加载并变换所有模型
|
||||
transformed_meshes = load_and_transform_models(base_path, dict_origin, blank_path, json_name)
|
||||
transformed_meshes = load_and_transform_models(base_path, dict_origin, json_name)
|
||||
|
||||
if not transformed_meshes:
|
||||
print("没有加载到任何模型,请检查错误信息")
|
||||
else:
|
||||
print(f"成功加载并变换了 {len(transformed_meshes)} 个模型")
|
||||
|
||||
render_to_texture(transformed_meshes, output_image_path, background_color=[0.9, 0.9, 0.9])
|
||||
render_to_texture(transformed_meshes, output_image_path)
|
||||
|
||||
if is_show:
|
||||
# 可视化所有模型
|
||||
@@ -457,12 +489,9 @@ if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
|
||||
# batch_id = args.batch_id
|
||||
batch_id = "test" # 1113-MY-4
|
||||
batch_id = "9910032"
|
||||
|
||||
base_path = f"{print_factory_type_dir}/{batch_id}/"
|
||||
blank_path = f"{print_factory_type_dir}/blank/blank_bias/blank2.obj"
|
||||
# blank_path = f"{print_factory_type_dir}/blank/blank_bias/blank_small.obj"
|
||||
print(f"blank_path={blank_path}")
|
||||
|
||||
load_show_save(base_path, {}, blank_path, batch_id, True)
|
||||
load_show_save(base_path, {}, batch_id, False)
|
||||
|
||||
Reference in new issue
Block a user