first commit
This commit is contained in:
commit
677a836569
29 files changed
+1785
No files matched your search
@@ -0,0 +1,96 @@
|
||||
import os, sys, time, shutil, subprocess, shlex
|
||||
import platform
|
||||
if platform.system() == 'Windows':
|
||||
sys.path.append('e:\\libs\\')
|
||||
else:
|
||||
sys.path.append('/data/deploy/make3d/make2/libs/')
|
||||
import config, libs, libs_db
|
||||
|
||||
def load_model(pid):
|
||||
cmd = f'{config.rcbin} {config.r1["init"]} -load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}"'
|
||||
print(cmd)
|
||||
cmd = shlex.split(cmd)
|
||||
res = subprocess.run(cmd)
|
||||
|
||||
def get_rcver():
|
||||
rcbin = '"C:\\Program Files\\Capturing Reality\\RealityCapture\\RealityCapture.exe"'
|
||||
if os.path.getsize(rcbin[1:-1]) == 20783616:
|
||||
return 1
|
||||
else:
|
||||
return 2
|
||||
|
||||
def make3d(pid):
|
||||
simplify_value = 1000000 * libs.getHeadCount(pid)
|
||||
add_photo3 = ' '
|
||||
if os.path.exists(os.path.join(config.workdir, pid, 'photo3')):
|
||||
add_photo3 = ' -addFolder "' + os.path.join(config.workdir, pid, 'photo3') + '" -align -align '
|
||||
|
||||
if get_rcver() == 1: # old version
|
||||
cmd = f'{config.rcbin} {config.r1["init"]} \
|
||||
-addFolder "{os.path.join(config.workdir, pid, "photo1")}" -addFolder "{os.path.join(config.workdir, pid, "photo2")}" {add_photo3} \
|
||||
-importControlPointsMeasurements "{os.path.join(config.workdir, pid, f"{pid}.controlPoints.csv")}" \
|
||||
-align -save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}"'
|
||||
print(cmd)
|
||||
cmd = shlex.split(cmd)
|
||||
res = subprocess.run(cmd)
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 定位点导入完成')
|
||||
|
||||
# defind_distance
|
||||
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 定义定位点距离完成')
|
||||
|
||||
cmd = f'{config.rcbin} {config.r1["init"]} -load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -update \
|
||||
-setReconstructionRegion "{os.path.join(config.workdir, pid, f"{pid}.rcbox")}" \
|
||||
-mvs -modelSelectMaximalConnectedComponent -modelInvertSelection -modelRemoveSelectedTriangles -closeHoles -clean -simplify {simplify_value} -smooth -unwrap -calculateTexture -renameModel {pid} -exportModel "{pid} {os.path.join(config.workdir, pid, "output", f"{pid}.obj")}" "d:\\make2\\config\\ModelExportParams102.xml" -quit'
|
||||
print(cmd)
|
||||
cmd = shlex.split(cmd)
|
||||
res = subprocess.run(cmd)
|
||||
else: # new version
|
||||
if libs.aliyun_face(pid) and libs.get_ps_type(pid) == 1:
|
||||
calulate_type = 'calculateHighModel'
|
||||
else:
|
||||
calulate_type = 'calculateNormalModel'
|
||||
cmd = f'{config.rcbin} {config.r2["init"]} -setInstanceName {pid} \
|
||||
-load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" \
|
||||
-{calulate_type} \
|
||||
-selectLargestModelComponent -invertTrianglesSelection -removeSelectedTriangles -simplify {simplify_value} -smooth -closeHoles -cleanModel -calculateTexture \
|
||||
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" \
|
||||
-exportSelectedModel "{os.path.join(config.workdir, pid, "output", f"{pid}.obj")}" "d:\\make2\\config\\ModelExportParams.xml" -quit'
|
||||
print(cmd)
|
||||
cmd = shlex.split(cmd)
|
||||
res = subprocess.run(cmd)
|
||||
|
||||
def step2(pid):
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 开始建模任务step2')
|
||||
if os.path.exists(os.path.join(config.sharedir, pid)) and not os.path.exists(os.path.join(config.workdir, pid)):
|
||||
shutil.move(os.path.join(config.sharedir, pid), config.workdir)
|
||||
else:
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 目录{os.path.join(config.sharedir, pid)}不存在,或{os.path.join(config.workdir, pid)}已存在')
|
||||
# return
|
||||
start_time = time.time()
|
||||
make3d(pid)
|
||||
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 建模任务step2完成,共费时{libs.diff_time(start_time)},任务已提交到step3')
|
||||
# 更新本地任务状态,加入step3任务队列
|
||||
|
||||
os.system(f'python d:\\make2\\main_step3.py {pid}')
|
||||
|
||||
def main(pid):
|
||||
if pid == '0':
|
||||
while True:
|
||||
# 取本地mysql队列任务,完成第二步的建模任务
|
||||
|
||||
step2(pid)
|
||||
else:
|
||||
step2(pid)
|
||||
|
||||
if __name__ == '__main__':
|
||||
# 取本地mysql队列任务,完成第二步的建模任务
|
||||
# 默认循环值守,可传参数运行单一任务,以方便调试
|
||||
pid = '0'
|
||||
if len(sys.argv) > 1:
|
||||
pids = sys.argv[1].split(',')
|
||||
for pid in pids:
|
||||
main(pid)
|
||||
exit()
|
||||
main(pid)
|
||||
Reference in new issue
Block a user