|
|
|
|
@ -15,11 +15,16 @@ import config, libs, libs_db,main_service_db
@@ -15,11 +15,16 @@ import config, libs, libs_db,main_service_db
|
|
|
|
|
def check_pid_file(pid): |
|
|
|
|
#检测是否存在目录 |
|
|
|
|
path = os.path.join(config.workdir, pid) |
|
|
|
|
# if os.path.exists(path): |
|
|
|
|
# shutil.rmtree(path) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(path): |
|
|
|
|
#不存在就在就下载目录 |
|
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 开始计算相机位姿...') |
|
|
|
|
start_time = time.time() |
|
|
|
|
libs.down_from_oss(config.oss_bucket, config.workdir, pid,100,"2") |
|
|
|
|
libs.down_from_oss(config.oss_bucket, config.workdir, pid) |
|
|
|
|
|
|
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} 图片下载完成,共费时{libs.diff_time(start_time)}') |
|
|
|
|
else: |
|
|
|
|
#存在的话就检测是否有photo1 和 photo2 之外的目录或者文件,有的话就删除 |
|
|
|
|
@ -41,14 +46,14 @@ def check_pid_file(pid):
@@ -41,14 +46,14 @@ def check_pid_file(pid):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#根据参数初始化操作 |
|
|
|
|
def cmd_run(pid,usePhoto = "2",lock=False): |
|
|
|
|
def cmd_run(pid,usePhoto = "1",lock=False): |
|
|
|
|
pid = str(pid) |
|
|
|
|
#检测文件并且下载处理文件 |
|
|
|
|
check_pid_file(pid) |
|
|
|
|
|
|
|
|
|
start_time = time.time() |
|
|
|
|
#文件路径 |
|
|
|
|
#photo1_path = os.path.join(config.workdir, pid, 'photo1') |
|
|
|
|
photo1_path = os.path.join(config.workdir, pid, 'photo1') |
|
|
|
|
photo2_path = os.path.join(config.workdir, pid, 'photo2') |
|
|
|
|
#计算文件里的数量 |
|
|
|
|
#photos1_count = len(os.listdir(photo1_path)) |
|
|
|
|
@ -59,65 +64,72 @@ def cmd_run(pid,usePhoto = "2",lock=False):
@@ -59,65 +64,72 @@ def cmd_run(pid,usePhoto = "2",lock=False):
|
|
|
|
|
if lock: |
|
|
|
|
exportxmp = ' -exportXMP "D:\\make2\\config\\exportXMP.config.lock.xml" ' |
|
|
|
|
else: |
|
|
|
|
exportxmp = ' -exportXMP "D:\\make2\\config\\exportXMP.config.xml" ' |
|
|
|
|
exportxmp = ' -exportXMP "D:\\make2\\config\\exportXMP.config.lock.xml" ' |
|
|
|
|
|
|
|
|
|
usePhoto = "photo2" |
|
|
|
|
usePhoto = "photo1" |
|
|
|
|
|
|
|
|
|
#执行命令 |
|
|
|
|
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 \ |
|
|
|
|
cmd = f'{config.rcbin} -setInstanceName "{pid}" \ |
|
|
|
|
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}"\ |
|
|
|
|
-addFolder "{os.path.join(config.workdir, pid, usePhoto)}" -set "sfmMaxFeatureReprojectionError=2" -selectAllImages \ |
|
|
|
|
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" \ |
|
|
|
|
-align -align \ |
|
|
|
|
-align -align -align -align -align\ |
|
|
|
|
{exportxmp} \ |
|
|
|
|
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -quit' |
|
|
|
|
print(cmd) |
|
|
|
|
cmd = shlex.split(cmd) |
|
|
|
|
res = subprocess.run(cmd) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#根据参数转变路劲,复制photo1 里的xmp 文件到 photo2 里,或者 photo2 里的xmp 文件到 photo1 里 |
|
|
|
|
# sourceFile = photo1_path |
|
|
|
|
sourceFile = photo1_path |
|
|
|
|
targetFile = photo2_path |
|
|
|
|
# if usePhoto == "photo2": |
|
|
|
|
# sourceFile = photo2_path |
|
|
|
|
# targetFile = photo1_path |
|
|
|
|
# #复制xmp文件 |
|
|
|
|
# for xmp in os.listdir(sourceFile): |
|
|
|
|
# if xmp.endswith('.xmp'): |
|
|
|
|
# if usePhoto == "photo1": |
|
|
|
|
# shutil.copy(os.path.join(sourceFile, xmp), os.path.join(targetFile,xmp.replace('_1.xmp', '_8.xmp'))) |
|
|
|
|
if usePhoto == "photo2": |
|
|
|
|
sourceFile = photo2_path |
|
|
|
|
targetFile = photo1_path |
|
|
|
|
#复制xmp文件 |
|
|
|
|
for xmp in os.listdir(sourceFile): |
|
|
|
|
if xmp.endswith('.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'))) |
|
|
|
|
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("坐标复制完成") |
|
|
|
|
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} -setInstanceName {pid} \ |
|
|
|
|
-load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}"\ |
|
|
|
|
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" \ |
|
|
|
|
{libs.get_defineDistances(psid)} -update -align -align -align -align -align {config.r2["setRegion"]} \ |
|
|
|
|
-addFolder "{os.path.join(config.workdir, pid, usePhoto)}" \ |
|
|
|
|
-addFolder "{os.path.join(config.workdir, pid, "photo2")}"\ |
|
|
|
|
-selectImage "{os.path.join(config.workdir,pid,"photo1")}/*" -enableTexturingAndColoring false \ |
|
|
|
|
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" -align -align -align \ |
|
|
|
|
{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 false \ |
|
|
|
|
-selectImage "{os.path.join(config.workdir,pid,"photo2")}/*" -enableTexturingAndColoring true \ |
|
|
|
|
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -quit' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-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} step1完成,共费时{libs.diff_time(start_time)}') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yes_or_not = input('是否step2?(y/n)') |
|
|
|
|
if yes_or_not == 'y': |
|
|
|
|
pass |
|
|
|
|
else: |
|
|
|
|
sys.exit(0)# yes_or_not = input('当前该影棚没有对应的对齐坐标,是否创建?(y/n)') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#调用step2 |
|
|
|
|
time.sleep(2) |
|
|
|
|
os.system(f'python main_step2.py {pid}') |
|
|
|
|
|