优化
This commit is contained in:
1 parent
3197efd6a3
commit
46dacc2f7c
7 files changed
+62
-13
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
import redis,sys,os,re,oss2
|
import redis,sys,os,re,oss2
|
||||||
import platform
|
import platform
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
from PIL import ImageGrab
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
#sys.path.append('e:\\libs\\')
|
#sys.path.append('e:\\libs\\')
|
||||||
sys.path.append('libs')
|
sys.path.append('libs')
|
||||||
@@ -218,3 +219,11 @@ def uploadControlPointsOss(pid):
|
|||||||
localfile = os.path.join(config.workdir,str(pid), f'{str(pid)}_wait/controlpoints0.dat')
|
localfile = os.path.join(config.workdir,str(pid), f'{str(pid)}_wait/controlpoints0.dat')
|
||||||
#进行上传
|
#进行上传
|
||||||
config.oss_bucket.put_object_from_file(filePath, localfile)
|
config.oss_bucket.put_object_from_file(filePath, localfile)
|
||||||
|
|
||||||
|
#截屏保存
|
||||||
|
def saveScreenImg(pid):
|
||||||
|
#获取当前的日志
|
||||||
|
if not os.path.exists(os.path.join("D:/screen/",time.strftime("%y-%m-%d", time.localtime()))):
|
||||||
|
os.makedirs(os.path.join("D:/screen/",time.strftime("%Y-%m-%d", time.localtime())))
|
||||||
|
screenshot = ImageGrab .grab()
|
||||||
|
screenshot.save(os.path.join("D:/screen/",time.strftime("%Y-%-%d'time .localtime()"),str(pid)+".png"))
|
||||||
@@ -117,7 +117,15 @@ def need_run_stepx(task_distributed_id):
|
|||||||
#查询改任务的最后一个状态
|
#查询改任务的最后一个状态
|
||||||
if result and result["finished_at"]:
|
if result and result["finished_at"]:
|
||||||
if result["step"] == "step1":
|
if result["step"] == "step1":
|
||||||
return "step2"
|
|
||||||
|
#如果是要执行 step2 ,并且当前主机是R11 R12 ,则要判断step1是否是当前的主机执行的
|
||||||
|
if hostname == "R11" or hostname == "R12":
|
||||||
|
if hostname != result["hostname"]:
|
||||||
|
return "no"
|
||||||
|
else:
|
||||||
|
return "step2"
|
||||||
|
else:
|
||||||
|
return "step2"
|
||||||
elif result["step"] == "step2":
|
elif result["step"] == "step2":
|
||||||
return "step3"
|
return "step3"
|
||||||
elif result["step"] == "step3":
|
elif result["step"] == "step3":
|
||||||
|
|||||||
+9
-1
@@ -58,8 +58,14 @@ def detect_markers(psid, pid):
|
|||||||
|
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
add_photo3 = ' '
|
add_photo3 = ' '
|
||||||
|
textpicCmd = ' '
|
||||||
if os.path.exists(os.path.join(config.workdir, pid, 'photo3')):
|
if os.path.exists(os.path.join(config.workdir, pid, 'photo3')):
|
||||||
add_photo3 = ' -addFolder "' + os.path.join(config.workdir, pid, 'photo3') + '" '
|
add_photo3 = ' -addFolder "' + os.path.join(config.workdir, pid, 'photo3') + '" '
|
||||||
|
|
||||||
|
textpicCmd ='-selectImage "'+os.path.join(config.workdir,pid,'photo3')+'\*" -enableTexturingAndColoring true'
|
||||||
|
textpicCmd ='-selectImage "'+os.path.join(config.workdir,pid,'photo2')+'\*" -enableTexturingAndColoring false'
|
||||||
|
else:
|
||||||
|
textpicCmd ='-selectImage "'+os.path.join(config.workdir,pid,'photo2')+'\*" -enableTexturingAndColoring true'
|
||||||
|
|
||||||
cmd = f'{config.rcbin} {config.r2["init"]} -setInstanceName {pid} \
|
cmd = f'{config.rcbin} {config.r2["init"]} -setInstanceName {pid} \
|
||||||
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" \
|
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" \
|
||||||
@@ -70,7 +76,7 @@ def detect_markers(psid, pid):
|
|||||||
-exportXMP "D:\\make2\\config\\exportXMP.config.xml" \
|
-exportXMP "D:\\make2\\config\\exportXMP.config.xml" \
|
||||||
-exportControlPointsMeasurements "{os.path.join(config.workdir, pid, f"{pid}.controlPoints.csv")}" "D:\\make2\\config\\exportControlPoints.config.xml" \
|
-exportControlPointsMeasurements "{os.path.join(config.workdir, pid, f"{pid}.controlPoints.csv")}" "D:\\make2\\config\\exportControlPoints.config.xml" \
|
||||||
-exportReconstructionRegion "{os.path.join(config.workdir, pid, f"{pid}.rcbox")}" \
|
-exportReconstructionRegion "{os.path.join(config.workdir, pid, f"{pid}.rcbox")}" \
|
||||||
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -quit'
|
{textpicCmd} -save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -quit'
|
||||||
print(cmd)
|
print(cmd)
|
||||||
cmd = shlex.split(cmd)
|
cmd = shlex.split(cmd)
|
||||||
res = subprocess.run(cmd)
|
res = subprocess.run(cmd)
|
||||||
@@ -182,6 +188,8 @@ def step1(pid, experience=False, makeloop=True,task_distributed_id="",isNoColorT
|
|||||||
libs.set_photo_join_type(config.workdir, pid, 'photo2', camcerIndex, mesh='0', texture='0')
|
libs.set_photo_join_type(config.workdir, pid, 'photo2', camcerIndex, mesh='0', texture='0')
|
||||||
|
|
||||||
|
|
||||||
|
#移除当前文件夹
|
||||||
|
shutil.rmtree(os.path.join(config.workdir, pid))
|
||||||
# TODO: 更新本地step1任务状态,加入step2任务队列
|
# TODO: 更新本地step1任务状态,加入step2任务队列
|
||||||
if task_distributed_id == "":#不是分布式任务的时候就自动往下个步骤走,是分布式任务的时候就就执行当前任务
|
if task_distributed_id == "":#不是分布式任务的时候就自动往下个步骤走,是分布式任务的时候就就执行当前任务
|
||||||
if makeloop:
|
if makeloop:
|
||||||
|
|||||||
+27
-3
@@ -1,5 +1,6 @@
|
|||||||
import os, sys, time, shutil, subprocess, shlex
|
import os, sys, time, shutil, subprocess, shlex
|
||||||
import platform
|
import platform
|
||||||
|
import pyautogui as ag
|
||||||
if platform.system() == 'Windows':
|
if platform.system() == 'Windows':
|
||||||
sys.path.append('e:\\libs\\')
|
sys.path.append('e:\\libs\\')
|
||||||
#sys.path.append('libs')
|
#sys.path.append('libs')
|
||||||
@@ -23,7 +24,7 @@ def get_rcver():
|
|||||||
def make3d(pid):
|
def make3d(pid):
|
||||||
if get_rcver() == 1: # old version
|
if get_rcver() == 1: # old version
|
||||||
#修改重建区域的大小
|
#修改重建区域的大小
|
||||||
common.change_rcbox_s(pid,"0.999")
|
common.change_rcbox_s(pid,"1")
|
||||||
#获取影棚id
|
#获取影棚id
|
||||||
# psid = libs.getPSid(pid)
|
# psid = libs.getPSid(pid)
|
||||||
# if int(psid) == 80:
|
# if int(psid) == 80:
|
||||||
@@ -34,6 +35,26 @@ def make3d(pid):
|
|||||||
#判断是否存在photo3
|
#判断是否存在photo3
|
||||||
if os.path.exists(os.path.join(config.workdir, pid, 'photo3')):
|
if os.path.exists(os.path.join(config.workdir, pid, 'photo3')):
|
||||||
add_photo3 = ' -addFolder "' + os.path.join(config.workdir, pid, 'photo3') + '" -align -align '
|
add_photo3 = ' -addFolder "' + os.path.join(config.workdir, pid, 'photo3') + '" -align -align '
|
||||||
|
#存在photo3 的情况下,photo2 不参与贴图
|
||||||
|
#遍历获取photo2 目录下的所有文件
|
||||||
|
directory = os.path.join(config.workdir, pid, 'photo2')
|
||||||
|
for root, dirs, files in os.walk(directory):
|
||||||
|
for file in files:
|
||||||
|
#判断file 是否以 _8.xmp 结尾
|
||||||
|
if file.endswith("_8.xmp") == False:
|
||||||
|
continue
|
||||||
|
#修改文件内容不参与贴图
|
||||||
|
libs.set_photo_join_type(config.workdir, pid, 'photo2', file.split("_")[0], mesh='0', texture='0')
|
||||||
|
else:
|
||||||
|
#设置photo2参与贴图,因为有的时候贴图会黑
|
||||||
|
directory = os.path.join(config.workdir, pid, 'photo2')
|
||||||
|
for root, dirs, files in os.walk(directory):
|
||||||
|
for file in files:
|
||||||
|
#判断file 是否以 _8.xmp 结尾
|
||||||
|
if file.endswith("_8.xmp") == False:
|
||||||
|
continue
|
||||||
|
#修改文件内容不参与贴图
|
||||||
|
libs.set_photo_join_type(config.workdir, pid, 'photo2', file.split("_")[0], mesh='0', texture='1')
|
||||||
|
|
||||||
if get_rcver() == 1: # old version
|
if get_rcver() == 1: # old version
|
||||||
|
|
||||||
@@ -97,14 +118,17 @@ def make3d(pid):
|
|||||||
print(cmd)
|
print(cmd)
|
||||||
cmd = shlex.split(cmd)
|
cmd = shlex.split(cmd)
|
||||||
res = subprocess.run(cmd)
|
res = subprocess.run(cmd)
|
||||||
|
#保存在导出
|
||||||
|
# common.saveScreenImg(pid)
|
||||||
|
# time.sleep(1)
|
||||||
|
# ag.hotkey('alt', 'f4')
|
||||||
time.sleep(3)
|
time.sleep(3)
|
||||||
#修改rcproj文件
|
#修改rcproj文件
|
||||||
flag = common.changeRcprojFile(pid)
|
flag = common.changeRcprojFile(pid)
|
||||||
if flag == False:
|
if flag == False:
|
||||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} rcproj文件不存在')
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} rcproj文件不存在')
|
||||||
return
|
return
|
||||||
#保存在导出
|
|
||||||
|
|
||||||
#创建指定文件夹
|
#创建指定文件夹
|
||||||
if not os.path.exists(os.path.join(config.workdir, pid, "output")):
|
if not os.path.exists(os.path.join(config.workdir, pid, "output")):
|
||||||
|
|||||||
+1
-1
@@ -207,7 +207,7 @@ def step3(pid,task_distributed_id=""):
|
|||||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 模型后道处理完成,共费时{libs.diff_time(start_time)}')
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 模型后道处理完成,共费时{libs.diff_time(start_time)}')
|
||||||
res = requests.post(config.urls['update_status_modelsuccess_url'], data={'id': pid})
|
res = requests.post(config.urls['update_status_modelsuccess_url'], data={'id': pid})
|
||||||
print('上传完成更新建模成功状态:', res.text)
|
print('上传完成更新建模成功状态:', res.text)
|
||||||
shutil.rmtree(os.path.join(config.workdir, pid), ignore_errors=True)
|
#shutil.rmtree(os.path.join(config.workdir, pid), ignore_errors=True)
|
||||||
libs_db.finish_task({"task_type": "make", "task_key": pid})
|
libs_db.finish_task({"task_type": "make", "task_key": pid})
|
||||||
if task_distributed_id:
|
if task_distributed_id:
|
||||||
#因为step2 和step3 是一起跑的,所以这一步先注释掉更新子表的finished_at
|
#因为step2 和step3 是一起跑的,所以这一步先注释掉更新子表的finished_at
|
||||||
|
|||||||
@@ -24,12 +24,12 @@ def readTask(key):
|
|||||||
return
|
return
|
||||||
pid = pid.decode('utf-8')
|
pid = pid.decode('utf-8')
|
||||||
psid = getPSid(pid)
|
psid = getPSid(pid)
|
||||||
#判断是否走新的建模系统
|
#判断是否走新的建模系统 2023-11-10 全部走新的建模系统
|
||||||
if libs_db.is_new_make_psid(psid) == False:
|
# if libs_db.is_new_make_psid(psid) == False:
|
||||||
#如果不是走新的建模系统就塞回原来的队列
|
# #如果不是走新的建模系统就塞回原来的队列
|
||||||
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())+"-该任务不是走新的建模任务,塞回原来的队列-"+pid)
|
# print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())+"-该任务不是走新的建模任务,塞回原来的队列-"+pid)
|
||||||
r.rpush('model:'+key,pid)
|
# r.rpush('model:'+key,pid)
|
||||||
return
|
# return
|
||||||
#新的建模系统
|
#新的建模系统
|
||||||
#psid = getPSid(pid)
|
#psid = getPSid(pid)
|
||||||
if key == "make10":
|
if key == "make10":
|
||||||
|
|||||||
+1
-1
@@ -89,4 +89,4 @@ if __name__ == '__main__':
|
|||||||
sizes = sys.argv[3].split(',')
|
sizes = sys.argv[3].split(',')
|
||||||
for pid in pids:
|
for pid in pids:
|
||||||
main(action, pid, sizes)
|
main(action, pid, sizes)
|
||||||
print('Usage: python cal_weight.py <pids>')
|
print('Usage: python cal_weight.py print <pids> 自定义尺寸/默认四个尺寸就不填')
|
||||||
Reference in new issue
Block a user