dongchangxi 6 months ago
parent
commit
6117a5f49d
  1. 5
      .gitignore
  2. 20
      apps/auto_convert3d_new.py
  3. 2
      timer/external_order_glbV2.py
  4. 6
      tools/pic_for_obj/image_rander_small.py

5
.gitignore vendored

@ -15,3 +15,8 @@ test/test1.py
timer/29.zip timer/29.zip
yj_local_build/main_step1.spec yj_local_build/main_step1.spec
yj_local_build/建模source_code.zip yj_local_build/建模source_code.zip
apps/__pycache__/fix_up_color_two_a.cpython-310.pyc
.gitignore
apps/__pycache__/ps_image_shadow_up_ag_two_a.cpython-310.pyc
apps/__pycache__/white_purification_v3.cpython-310.pyc
apps/__pycache__/white_purification_v4.cpython-310.pyc

20
apps/auto_convert3d_new.py

@ -36,13 +36,13 @@ def down_obj_fromoss(pid,order_id):
print("AAAAAAAAA",ossPath) print("AAAAAAAAA",ossPath)
path = os.path.join(workdir, 'print', pid) path = os.path.join(workdir, 'print', pid,order_id)
if not os.path.exists(path): os.makedirs(path) if not os.path.exists(path): os.makedirs(path)
# 根据前缀获取文件列表 # 根据前缀获取文件列表
prefix = f'objs/print/{pid}/' prefix = f'objs/print/{pid}/'
if ossPath != "": if ossPath != "":
prefix = os.path.join("objs","print",pid,ossPath,order_id) prefix = os.path.join("objs","print",pid,ossPath)
if "base/" in ossPath: if "base/" in ossPath:
prefix = os.path.join("objs","print",pid,ossPath) prefix = os.path.join("objs","print",pid,ossPath)
prefix = prefix.replace("\\","/") prefix = prefix.replace("\\","/")
@ -122,34 +122,34 @@ def team_check(r):
pid = str(pid) pid = str(pid)
orderId = str(orderId) orderId = str(orderId)
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), f'pid:{pid} repair_id:{repair_id} 生成团队审核模型 start model:IndependentRepairTeamcheckGLBQueue', ) #print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), f'pid:{pid} repair_id:{repair_id} 生成团队审核模型 start model:IndependentRepairTeamcheckGLBQueue', )
ossPath = down_obj_fromoss(pid,orderId) ossPath = down_obj_fromoss(pid,orderId)
obj_filename = f'{pid}.obj' obj_filename = f'{pid}.obj'
glb_filename = f'{orderId}.glb' glb_filename = f'{orderId}.glb'
print('开始转换obj文件为glb文件...') print('开始转换obj文件为glb文件...')
os.system(f'gltfpack -c -i {os.path.join(workdir, "print", pid, obj_filename)} -o {os.path.join(workdir, "print", pid, glb_filename)} -vt 16 -vc 16') os.system(f'gltfpack -c -i {os.path.join(workdir, "print", pid,orderId, obj_filename)} -o {os.path.join(workdir, "print", pid,orderId, glb_filename)} -vt 16 -vc 16')
#处理封面图 #处理封面图
#执行获取obj缩略图 #执行获取obj缩略图
print("执行获取obj全身缩略图脚本1111111111") print("执行获取obj全身缩略图脚本1111111111")
os.system(f'python d:\\make2\\tools\pic_for_obj\image_rander_small.py -pid {pid} -i D://print/{pid} -o D://print/{pid}') os.system(f'python d:\\make2\\tools\pic_for_obj\image_rander_small.py -pid {pid} -i D://print/{pid}/{orderId} -o D://print/{pid}/{orderId}')
print("判断是否存在封面图") print("判断是否存在封面图")
#判断文件是否存在,存在则上传到oss, 更新数据库内容 #判断文件是否存在,存在则上传到oss, 更新数据库内容
if os.path.exists(f'D://print/{pid}/{pid}_pic.png'): if os.path.exists(f'D://print/{pid}/{orderId}/{pid}_pic.png'):
#获取拍照订单的信息,从中得到拍照订单的信息 #获取拍照订单的信息,从中得到拍照订单的信息
uuid = get_p3d_info(str(pid)) uuid = get_p3d_info(str(pid))
if uuid != 0 and uuid != None and uuid != "": if uuid != 0 and uuid != None and uuid != "":
print("uuid",uuid) print("uuid",uuid)
config.oss_bucket_3d_view.put_object_from_file(f'{uuid}/3d_view.png', f'D://print/{pid}/{pid}_pic.png') config.oss_bucket_3d_view.put_object_from_file(f'{uuid}/3d_view.png', f'D://print/{pid}/{orderId}/{pid}_pic.png')
oss_client.put_object_from_file(f'glbs/print/order_id/{glb_filename}', os.path.join(workdir, "print", pid, glb_filename)) oss_client.put_object_from_file(f'glbs/print/order_id/{glb_filename}', os.path.join(workdir, "print", pid,orderId, glb_filename))
#对文件进行白色提纯处理 #对文件进行白色提纯处理
imagePath = os.path.join(workdir, 'print', pid,pid+"Tex1.jpg") imagePath = os.path.join(workdir, 'print', pid,orderId,pid+"Tex1.jpg")
print("开始处理白色提纯") print("开始处理白色提纯")
#white_purification.white_purification_utils(imagePath) #white_purification.white_purification_utils(imagePath)
os.system(f'python D:\\make2\\apps\white_purification_v4.py -i {imagePath}') os.system(f'python D:\\make2\\apps\white_purification_v4.py -i {imagePath}')
@ -165,7 +165,7 @@ def team_check(r):
print(f'{update_repair_status_url}?id={repair_id}') print(f'{update_repair_status_url}?id={repair_id}')
res = requests.get(f'{update_repair_status_url}?id={repair_id}') res = requests.get(f'{update_repair_status_url}?id={repair_id}')
print('更新团队审核状态:', res.text) print('更新团队审核状态:', res.text)
shutil.rmtree(os.path.join(workdir, 'print', pid), ignore_errors=True) #shutil.rmtree(os.path.join(workdir, 'print', pid,orderId), ignore_errors=True)
print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), f'pid:{pid} 生成团队审核模型 end') print(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()), f'pid:{pid} 生成团队审核模型 end')
def get_p3d_info(pid): def get_p3d_info(pid):

2
timer/external_order_glbV2.py

@ -235,7 +235,7 @@ def export_and_update_glbs(pid,order_ids):
print(res.text) print(res.text)
#执行获取obj缩略图 #执行获取obj缩略图
print("执行获取obj全身缩略图脚本") print("执行获取obj全身缩略图脚本")
os.system(f'python d:\\make2\\tools\pic_for_obj\image_rander_small.py -pid {pid} -i D://print -o D://print/{pid}') os.system(f'python d:\\make2\\tools\pic_for_obj\image_rander_small.py -pid {pid} -i D://print/{pid} -o D://print/{pid}')
print("判断获取封面图是否存在0") print("判断获取封面图是否存在0")
#判断文件是否存在,存在则上传到oss, 更新数据库内容 #判断文件是否存在,存在则上传到oss, 更新数据库内容
if os.path.exists(f'D://print/{pid}/{pid}_pic.png'): if os.path.exists(f'D://print/{pid}/{pid}_pic.png'):

6
tools/pic_for_obj/image_rander_small.py

@ -86,7 +86,7 @@ def rander_image_and_check(args):
"""渲染图片""" """渲染图片"""
# 列出obj列表 # 列出obj列表
pid = args.pid pid = args.pid
pid_file_dir = os.path.join(args.input,pid) pid_file_dir = os.path.join(args.input)
if not os.path.exists(pid_file_dir): if not os.path.exists(pid_file_dir):
print(f"不存在{pid_file_dir}") print(f"不存在{pid_file_dir}")
return return
@ -125,10 +125,10 @@ def rander_image_and_check(args):
start_import = time.time() start_import = time.time()
print("===============", os.path.join(args.input, pid, obj_file)) print("===============", os.path.join(args.input, pid, obj_file))
with stdout_redirected(to=os.devnull): with stdout_redirected(to=os.devnull):
bpy.ops.import_scene.obj(filepath=os.path.join(args.input, pid, obj_file)) bpy.ops.import_scene.obj(filepath=os.path.join(args.input, obj_file))
print( print(
f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}: import pid: {pid} done in {time.time() - start_import:.2f}s') f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())}: import pid: {pid} done in {time.time() - start_import:.2f}s')
texture_path = os.path.join(args.input, pid, texture_file) texture_path = os.path.join(args.input,texture_file)
materials = bpy.data.materials materials = bpy.data.materials
for material in materials: for material in materials:
# 确保材质使用节点树 # 确保材质使用节点树

Loading…
Cancel
Save