程序优化
This commit is contained in:
1 parent
e83deda268
commit
e1a7647fcb
16 files changed
+634
-91
No files matched your search
+27
-8
@@ -30,18 +30,21 @@ def check_pid_file(pid):
|
||||
else:
|
||||
shutil.rmtree(os.path.join(path, file))
|
||||
|
||||
#判断photo1 和 photo2 目录里的文件是否存在xmp 文件,不存在的话就删除
|
||||
#判断photo1 和 photo2 目录里的文件是否存在xmp 文件,存在的话就删除
|
||||
for file in os.listdir(os.path.join(path, 'photo1')):
|
||||
if not file.endswith('.xmp'):
|
||||
if file.endswith('.xmp'):
|
||||
os.remove(os.path.join(path, 'photo1', file))
|
||||
|
||||
for file in os.listdir(os.path.join(path, 'photo2')):
|
||||
if not file.endswith('.xmp'):
|
||||
if file.endswith('.xmp'):
|
||||
os.remove(os.path.join(path, 'photo2', file))
|
||||
|
||||
|
||||
#根据参数初始化操作
|
||||
def cmd_run(pid,usePhoto = "1",lock=False):
|
||||
pid = str(pid)
|
||||
#检测文件并且下载处理文件
|
||||
check_pid_file(pid)
|
||||
|
||||
start_time = time.time()
|
||||
#文件路径
|
||||
@@ -61,7 +64,7 @@ def cmd_run(pid,usePhoto = "1",lock=False):
|
||||
usePhoto = "photo"+str(usePhoto)
|
||||
|
||||
#执行命令
|
||||
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")}" \
|
||||
-addFolder "{os.path.join(config.workdir, pid, usePhoto)}" -selectAllImages \
|
||||
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" \
|
||||
@@ -81,20 +84,36 @@ def cmd_run(pid,usePhoto = "1",lock=False):
|
||||
#复制xmp文件
|
||||
for xmp in os.listdir(sourceFile):
|
||||
if xmp.endswith('.xmp'):
|
||||
shutil.copy(os.path.join(sourceFile, xmp), os.path.join(targetFile,xmp))
|
||||
if usePhoto == "photo1":
|
||||
shutil.copy(os.path.join(sourceFile, xmp), os.path.join(targetFile,xmp.replace('_1.xmp', '_8.xmp')))
|
||||
|
||||
if usePhoto == "photo2":
|
||||
shutil.copy(os.path.join(sourceFile, xmp), os.path.join(targetFile,xmp.replace('_8.xmp', '_1.xmp')))
|
||||
|
||||
#如果是photo2的话,就要将photo2 的 xmp 重命名成 _8.xmp
|
||||
# if usePhoto == "photo2":
|
||||
# for xmp in os.listdir(sourceFile):
|
||||
# if xmp.endswith('.xmp'):
|
||||
# #重名名.xmp 结尾的文件
|
||||
# os.rename(os.path.join(sourceFile, xmp), os.path.join(sourceFile,xmp.replace('_1.xmp', '_8.xmp')))
|
||||
# print("坐标复制完成")
|
||||
# exit()
|
||||
|
||||
#将两组图片进行重新对齐 然后重建区域
|
||||
psid = libs.getPSid(pid)
|
||||
cmd = f'{config.rcbin} {config.r2["init"]} -setInstanceName {pid} \
|
||||
cmd = f'{config.rcbin} -setInstanceName {pid} \
|
||||
-load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" {config.r["setTextureFalse"]} \
|
||||
-addFolder "{targetFile}" -selectAllImages \
|
||||
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" \
|
||||
{libs.get_defineDistances(psid)} -update -align -align {config.r2["setRegion"]} \
|
||||
{exportxmp} \
|
||||
-exportReconstructionRegion "{os.path.join(config.workdir, pid, f"{pid}.rcbox")}" \
|
||||
-selectImage "'+os.path.join(config.workdir,pid,'photo2')+'\*" -enableTexturingAndColoring true'
|
||||
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}"'
|
||||
-selectImage "{os.path.join(config.workdir,pid,"photo2")}/*" -enableTexturingAndColoring true \
|
||||
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -quit'
|
||||
|
||||
|
||||
|
||||
|
||||
print(cmd)
|
||||
cmd = shlex.split(cmd)
|
||||
res = subprocess.run(cmd)
|
||||
|
||||
Reference in new issue
Block a user