first commit
This commit is contained in:
commit
677a836569
29 files changed
+1785
No files matched your search
@@ -0,0 +1,98 @@
|
||||
import os, sys, time, shutil, subprocess, shlex, json
|
||||
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 upload_xmp(pid):
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 上传xmp文件之前先删除oss上的xmp文件所在目录...')
|
||||
config.oss_bucket.delete_object(f'xmps/{pid}/')
|
||||
start_time = time.time()
|
||||
workdir = os.path.join(config.workdir, pid)
|
||||
psid = libs.getPSid(pid)
|
||||
config.oss_bucket.put_object_from_file(f'xmps/{psid}/{psid}.rcbox', os.path.join(workdir, f'{pid}.rcbox'))
|
||||
for xmp in os.listdir(os.path.join(workdir, 'photo1')):
|
||||
if xmp.endswith('.xmp'):
|
||||
config.oss_bucket.put_object_from_file(f'xmps/{psid}/mesh/{xmp}', os.path.join(workdir, 'photo1', xmp))
|
||||
for xmp in os.listdir(os.path.join(workdir, 'photo2')):
|
||||
if xmp.endswith('.xmp'):
|
||||
config.oss_bucket.put_object_from_file(f'xmps/{psid}/texture/{xmp}', os.path.join(workdir, 'photo2', xmp))
|
||||
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} xmp文件上传完成,共费时{time.time() - start_time}秒')
|
||||
|
||||
def main(pid):
|
||||
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)
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} 图片下载完成,共费时{libs.diff_time(start_time)}')
|
||||
|
||||
start_time = time.time()
|
||||
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))
|
||||
photos2_count = len(os.listdir(photo2_path))
|
||||
if photos1_count + photos2_count < 164:
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} photo1数量{photos1_count} photo2数量{photos2_count},未能覆盖所有相机,是否继续计算相机位姿?')
|
||||
continue_or_not = input('是否继续计算相机位姿?(y/n)')
|
||||
if continue_or_not == 'y':
|
||||
pass
|
||||
else:
|
||||
sys.exit(0)
|
||||
|
||||
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, "photo1")}" -selectAllImages \
|
||||
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" \
|
||||
-align -align \
|
||||
-exportXMP "D:\\make2\\config\\exportXMP.config.xml" \
|
||||
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -quit'
|
||||
print(cmd)
|
||||
cmd = shlex.split(cmd)
|
||||
res = subprocess.run(cmd)
|
||||
|
||||
# TODO:加入report相机位姿质量评估
|
||||
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} photo1相机位姿完成,共费时{libs.diff_time(start_time)}')
|
||||
|
||||
for xmp in os.listdir(photo1_path):
|
||||
if xmp.endswith('.xmp'):
|
||||
shutil.copy(os.path.join(photo1_path, xmp), os.path.join(photo2_path, xmp.replace('_1.xmp', '_8.xmp')))
|
||||
|
||||
psid = libs.getPSid(pid)
|
||||
cmd = f'{config.rcbin} {config.r2["init"]} -setInstanceName {pid} \
|
||||
-load "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" {config.r["setTextureFalse"]} \
|
||||
-addFolder "{os.path.join(config.workdir, pid, "photo2")}" -selectAllImages \
|
||||
-detectMarkers "D:\\make2\\config\\detectMarkers.config.xml" \
|
||||
{libs.get_defineDistances(config.ps_floor_sticker.get(psid, config.ps_floor_sticker["default"]))} -align -align -update {config.r2["setRegion"]} \
|
||||
-exportXMP "D:\\make2\\config\\exportXMP.config.xml" \
|
||||
-exportReconstructionRegion "{os.path.join(config.workdir, pid, f"{pid}.rcbox")}" \
|
||||
-save "{os.path.join(config.workdir, pid, f"{pid}.rcproj")}" -quit'
|
||||
print(cmd)
|
||||
cmd = shlex.split(cmd)
|
||||
res = subprocess.run(cmd)
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} photo2相机位姿完成,共费时{libs.diff_time(start_time)}')
|
||||
|
||||
# TODO:加入report相机位姿质量评估
|
||||
upload_or_not = input('是否上传oss?(y/n)')
|
||||
if upload_or_not == 'y':
|
||||
upload_xmp(pid)
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} xmp文件上传完成,共费时{libs.diff_time(start_time)}')
|
||||
|
||||
delete_or_not = input('是否删除本地文件?(y/n)')
|
||||
if delete_or_not == 'y':
|
||||
shutil.rmtree(os.path.join(config.workdir, pid))
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} 本地文件已删除')
|
||||
else:
|
||||
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} {pid} 本地文件未删除')
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) == 2:
|
||||
pids = sys.argv[1].split(',')
|
||||
for pid in pids:
|
||||
main(pid)
|
||||
else:
|
||||
print(f'useage: python {sys.argv[0]} pid1,pid2,pid3')
|
||||
sys.exit(1)
|
||||
Reference in new issue
Block a user