64 lines
2.3 KiB
Python
64 lines
2.3 KiB
Python
import os, sys, datetime, subprocess, shlex, shutil, requests, time, json
|
|
import config
|
|
|
|
def diff_time(start_time, end_time):
|
|
d = end_time - start_time
|
|
m = d.microseconds
|
|
return str(d.seconds // 60) + ":" + str(d.seconds % 60) + ":" + str(m)[:-3]
|
|
|
|
def getPSid(pid):
|
|
res = requests.get(get_psid_url, params={'pid': pid})
|
|
res = json.loads(res.text)
|
|
return str(res['data'])
|
|
|
|
if __name__ == '__main__':
|
|
start = datetime.datetime.now()
|
|
if len(sys.argv) == 2:
|
|
input_path = sys.argv[1]
|
|
else:
|
|
print('usage: python rc.py [pid_path]')
|
|
exit(1)
|
|
input_path = os.path.abspath(input_path)
|
|
pid = input_path.split('\\')[-1]
|
|
output_path = input_path + '\\output\\'
|
|
ImagesGeometry = os.path.join(input_path, "photo1")
|
|
ImagesTexture = os.path.join(input_path, "photo2")
|
|
|
|
rcbin = '"C:\\Program Files\\Capturing Reality\\RealityCapture\\RealityCapture.exe"'
|
|
get_psid_url = 'https://mp.api.suwa3d.com/api/customerP3dLog/photoStudio'
|
|
psid = getPSid(pid)
|
|
|
|
config_path = 'D:\\apps\\config10\\'
|
|
xmps_mesh_path = config_path + f'xmps\\{psid}\\mesh\\'
|
|
xmps_texture_path = config_path + f'xmps\\{psid}\\texture\\'
|
|
|
|
ps_region = psid + '.rcbox'
|
|
|
|
shutil.rmtree(output_path, ignore_errors=True)
|
|
os.system('mkdir ' + output_path)
|
|
os.system('xcopy /Y ' + xmps_mesh_path + '*.* ' + ImagesGeometry)
|
|
os.system('xcopy /Y ' + xmps_texture_path + '*.* ' + ImagesTexture)
|
|
|
|
cmd = rcbin + \
|
|
' -disableOnlineCommunication ' + \
|
|
' -silent ' + output_path + \
|
|
' -addFolder "' + ImagesGeometry + '"' + \
|
|
' -align ' + \
|
|
' -addFolder "' + ImagesTexture + '"' + \
|
|
' -align -align' + \
|
|
' -setReconstructionRegion "' + config_path + ps_region + '" ' + \
|
|
' -mvs ' + \
|
|
' -modelSelectMaximalConnectedComponent -modelInvertSelection -modelRemoveSelectedTriangles -clean ' + \
|
|
' -simplify ' + simplify_value + ' ' + \
|
|
' -smooth ' + \
|
|
' -calculateTexture ' + \
|
|
' -renameModel ' + pid + ' ' + \
|
|
' -exportModel ' + pid + ' "' + output_path + '\\' + pid + '.obj" "' + config_path + 'ModelExportParams102.xml" '
|
|
|
|
print(cmd)
|
|
cmd = shlex.split(cmd)
|
|
subprocess.run(cmd)
|
|
|
|
end = datetime.datetime.now()
|
|
print('Time: ' + diff_time(start, end))
|