|
|
|
|
@ -73,30 +73,54 @@ def filter_dark_texture_image(pid):
@@ -73,30 +73,54 @@ def filter_dark_texture_image(pid):
|
|
|
|
|
|
|
|
|
|
def detect_markers(psid, pid): |
|
|
|
|
def fix_region(): |
|
|
|
|
region_filename = os.path.join(config['workdir'], pid, f'{pid}.rcbox') |
|
|
|
|
with open(region_filename, 'r') as f: |
|
|
|
|
lines = f.readlines() |
|
|
|
|
lines = [line.replace('"NONE" globalCoordinateSystemWkt="NONE" globalCoordinateSystemName="NONE"', '"+proj=geocent +ellps=WGS84 +no_defs" globalCoordinateSystemName="local:1 - Euclidean"') for line in lines] |
|
|
|
|
|
|
|
|
|
#判断是否存在rcbox |
|
|
|
|
region_filename = os.path.join(config["workdir"], pid, "a.rcbox") |
|
|
|
|
while True: |
|
|
|
|
if os.path.exists(region_filename): |
|
|
|
|
print("region_filename",region_filename) |
|
|
|
|
with open(region_filename, 'r') as f: |
|
|
|
|
lines = f.readlines() |
|
|
|
|
lines = [line.replace('"NONE" globalCoordinateSystemWkt="NONE" globalCoordinateSystemName="NONE"', '"+proj=geocent +ellps=WGS84 +no_defs" globalCoordinateSystemName="local:1 - Euclidean"') for line in lines] |
|
|
|
|
shutil.copyfile(os.path.join(config['workdir'], 'xmps','stand.rcbox'), os.path.join(config['workdir'], pid,f"{pid}.rcbox")) |
|
|
|
|
break |
|
|
|
|
else: |
|
|
|
|
time.sleep(10) |
|
|
|
|
print(f"不存在{region_filename}") |
|
|
|
|
start_time = time.time() |
|
|
|
|
textpicCmd ='-selectImage "'+os.path.join(config['workdir'],pid,'photo2')+'\*" -enableTexturingAndColoring true' |
|
|
|
|
|
|
|
|
|
#获取当前的工作目录 |
|
|
|
|
dirCurr = os.getcwd() |
|
|
|
|
|
|
|
|
|
shutil.copyfile(os.path.join(config['workdir'], 'xmps','stand.rcbox'), os.path.join(config['workdir'], pid,f"{pid}.rcbox")) |
|
|
|
|
rcboxfile = os.path.join(config["workdir"], pid, f"{pid}.rcbox") |
|
|
|
|
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")}" {config["r"]["setTextureFalse"]} -align -addFolder "{os.path.join(config["workdir"], pid, "photo2")}" \ |
|
|
|
|
-align -selectAllImages \ |
|
|
|
|
-detectMarkers "{dirCurr}\detectMarkers.config.xml" \ |
|
|
|
|
-defineDistance 36h11:001 36h11:002 1 -defineDistance 36h11:002 36h11:004 1 -defineDistance 36h11:004 36h11:003 1 -defineDistance 36h11:003 36h11:001 1 -align -align -update {config["r2"]["setRegion"]} \ |
|
|
|
|
-exportXMP "{dirCurr}\exportXMP.config.xml" \ |
|
|
|
|
-exportControlPointsMeasurements "{os.path.join(config["workdir"], pid, f"{pid}.controlPoints.csv")}" "{dirCurr}\exportControlPoints.config.xml" \ |
|
|
|
|
-exportReconstructionRegion "{os.path.join(config["workdir"], pid, f"{pid}.rcbox")}" \ |
|
|
|
|
-addFolder "{os.path.join(config["workdir"], pid, "photo1")}" {config["r"]["setTextureFalse"]} -detectMarkers "{dirCurr}\detectMarkers_1.5.config.xml"\ |
|
|
|
|
-addFolder "{os.path.join(config["workdir"], pid, "photo2")}" -align -detectMarkers "{dirCurr}\detectMarkers_1.5.config.xml" \ |
|
|
|
|
-align -align -align -align -detectMarkers "{dirCurr}\detectMarkers_1.5.config.xml" -align\ |
|
|
|
|
-defineDistance 36h11:007 36h11:008 0.21\ |
|
|
|
|
-align -align -update\ |
|
|
|
|
-setReconstructionRegion "{rcboxfile}"\ |
|
|
|
|
-exportControlPointsMeasurements "{os.path.join(config["workdir"], pid, f"{pid}.controlPoints.csv")}" "{dirCurr}\exportControlPoints.config.xml"\ |
|
|
|
|
-exportReconstructionRegion "{os.path.join(config["workdir"], pid, f"a.rcbox")}" \ |
|
|
|
|
{textpicCmd} -save "{os.path.join(config["workdir"], pid, f"{pid}.rcproj")}" -quit' |
|
|
|
|
|
|
|
|
|
#{config["r2"]["setRegion1"]}\ |
|
|
|
|
# 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")}" {config["r"]["setTextureFalse"]} \ |
|
|
|
|
# -addFolder "{os.path.join(config["workdir"], pid, "photo2")}" -align -detectMarkers "{dirCurr}\detectMarkers_1.5.config.xml" \ |
|
|
|
|
# -align -align -align -align -selectAllImages -detectMarkers "{dirCurr}\detectMarkers_1.5.config.xml" \ |
|
|
|
|
# -defineDistance 36h11:001 36h11:002 1 -defineDistance 36h11:002 36h11:004 1 -defineDistance 36h11:004 36h11:003 1 -defineDistance 36h11:003 36h11:001 1 -align -align -update {config["r2"]["setRegion"]} \ |
|
|
|
|
# -exportXMP "{dirCurr}\exportXMP.1.5.draft.config.xml" \ |
|
|
|
|
# -exportControlPointsMeasurements "{os.path.join(config["workdir"], pid, f"{pid}.controlPoints.csv")}" "{dirCurr}\exportControlPoints.config.xml" \ |
|
|
|
|
# -exportReconstructionRegion "{os.path.join(config["workdir"], pid, f"{pid}.rcbox")}" \ |
|
|
|
|
# {textpicCmd} -save "{os.path.join(config["workdir"], pid, f"{pid}.rcproj")}" -quit' |
|
|
|
|
|
|
|
|
|
print(cmd) |
|
|
|
|
cmd = shlex.split(cmd) |
|
|
|
|
cmd = shlex.split(cmd) |
|
|
|
|
res = subprocess.run(cmd) |
|
|
|
|
# print("res",res) |
|
|
|
|
time.sleep(3) |
|
|
|
|
fix_region() |
|
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid: {pid} 定位点检测完成, 共费时{diff_time(start_time)}') |
|
|
|
|
@ -116,28 +140,46 @@ def step1(pid,headsCount):
@@ -116,28 +140,46 @@ def step1(pid,headsCount):
|
|
|
|
|
def step2(pid,headsCount): |
|
|
|
|
dirCurr = os.getcwd() |
|
|
|
|
simplify_value = 1000000 * int(headsCount) |
|
|
|
|
rcboxfile = os.path.join(config["workdir"], pid, f"{pid}.rcbox") |
|
|
|
|
print("rcboxfile",rcboxfile) |
|
|
|
|
calulate_type = 'calculateNormalModel' |
|
|
|
|
cmd = f'{config["rcbin"]} {config["r2"]["init"]} -setInstanceName {pid} \ |
|
|
|
|
-load "{os.path.join(config["workdir"], pid, f"{pid}.rcproj")}" \ |
|
|
|
|
-load "{os.path.join(config["workdir"], pid, f"{pid}.rcproj")}" -setReconstructionRegion "{rcboxfile}"\ |
|
|
|
|
-{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")}" "{dirCurr}\\ModelExportParams.xml" -quit' |
|
|
|
|
|
|
|
|
|
# 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")}" "{dirCurr}\\ModelExportParams.xml" -quit' |
|
|
|
|
print(cmd) |
|
|
|
|
cmd = shlex.split(cmd) |
|
|
|
|
res = subprocess.run(cmd) |
|
|
|
|
print("res",res) |
|
|
|
|
#阻塞判断是否导出完成 |
|
|
|
|
while True: |
|
|
|
|
#判断 output 目录下是否存在 三个文件 |
|
|
|
|
files = os.listdir(os.path.join(config['workdir'], pid, "output")) |
|
|
|
|
if len(files) >= 3: |
|
|
|
|
break |
|
|
|
|
try: |
|
|
|
|
#判断 output 目录下是否存在 三个文件 |
|
|
|
|
files = os.listdir(os.path.join(config['workdir'], pid, "output")) |
|
|
|
|
if len(files) >= 3: |
|
|
|
|
time.sleep(5) |
|
|
|
|
break |
|
|
|
|
except Exception as e: |
|
|
|
|
time.sleep(5) |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#将导出的文件移动到指定目录 |
|
|
|
|
sourceDir = config["local_complate_build"] |
|
|
|
|
#判断目录是否存在,不存在就创建 |
|
|
|
|
if not os.path.exists(sourceDir): |
|
|
|
|
os.makedirs(sourceDir) |
|
|
|
|
if os.path.exists(os.path.join(sourceDir,pid)): |
|
|
|
|
#删除 |
|
|
|
|
os.removedirs(os.path.join(sourceDir,pid)) |
|
|
|
|
os.makedirs(os.path.join(sourceDir,pid)) |
|
|
|
|
|
|
|
|
|
#将 output 目录里的文件移动到指定目录 |
|
|
|
|
shutil.move(os.path.join(config['workdir'], pid, "output"),os.path.join(sourceDir,pid)) |
|
|
|
|
@ -149,10 +191,30 @@ def step2(pid,headsCount):
@@ -149,10 +191,30 @@ def step2(pid,headsCount):
|
|
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid:{pid} - 建模完成状态变更失败 - {e}') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#做xmps的坐标 |
|
|
|
|
def getXmps(pid): |
|
|
|
|
|
|
|
|
|
#从共享盘上下载对齐信息,判断是否有 |
|
|
|
|
print(f"判断是否存在 {os.path.join(config['workdir'], 'xmps','texture')} -- {os.path.exists(os.path.join(config['workdir'], 'xmps','texture'))}") |
|
|
|
|
if os.path.exists(os.path.join(config['workdir'], 'xmps','texture')) == False or os.path.exists(os.path.join(config['workdir'], 'xmps','mesh')) == False: |
|
|
|
|
print(f"检测不到对齐坐标,请先人工建一次模进行对齐,创建坐标,创建制定的坐标到 {os.path.join(config['workdir'], 'xmps','mesh')} 和 {os.path.join(config['workdir'], 'xmps','texture')}") |
|
|
|
|
return False |
|
|
|
|
else: |
|
|
|
|
#将共享盘的对齐信息复制到工作目录,photo1 和 photo2 |
|
|
|
|
shutil.copytree(os.path.join(config['workdir'], 'xmps','mesh'), os.path.join(config['workdir'], pid, 'photo1'),dirs_exist_ok=True) |
|
|
|
|
shutil.copytree(os.path.join(config['workdir'], 'xmps','texture'), os.path.join(config['workdir'], pid, 'photo2'),dirs_exist_ok=True) |
|
|
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main(pid,headsCount): |
|
|
|
|
step1(pid, headsCount) |
|
|
|
|
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
# step1("235558",1) |
|
|
|
|
# exit() |
|
|
|
|
try: |
|
|
|
|
url = config['urls']['update_status_modelsuccess_url'] |
|
|
|
|
if url == "": |
|
|
|
|
@ -191,13 +253,20 @@ if __name__ == '__main__':
@@ -191,13 +253,20 @@ if __name__ == '__main__':
|
|
|
|
|
try: |
|
|
|
|
while True: |
|
|
|
|
time.sleep(5) |
|
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 建模任务循环开始') |
|
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 建模任务循环开始,{needBuildDir}') |
|
|
|
|
for pid in os.listdir(needBuildDir): |
|
|
|
|
print("pid=",pid) |
|
|
|
|
|
|
|
|
|
res = getXmps(pid) |
|
|
|
|
if res == False: |
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
if not os.path.isdir(os.path.join(needBuildDir,pid)): |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#判断是否存在 canDo.txt 文件,如果不存在就跳过 |
|
|
|
|
if not os.path.exists(os.path.join(needBuildDir,pid,"canDo.txt")): |
|
|
|
|
print(f'不存在 canDo.txt- {os.path.join(needBuildDir,pid,"canDo.txt")}') |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
#读取 canDo.txt 文件内容 |
|
|
|
|
@ -208,6 +277,7 @@ if __name__ == '__main__':
@@ -208,6 +277,7 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
#判断文件夹里是否存在 do.txt , 如果存在就跳过,不存在就创建 |
|
|
|
|
if os.path.exists(os.path.join(needBuildDir,pid,"do.txt")): |
|
|
|
|
print("存在 do.txt 。则跳过处理") |
|
|
|
|
continue |
|
|
|
|
else: |
|
|
|
|
with open(os.path.join(needBuildDir,pid,"do.txt"),"w") as f: |
|
|
|
|
@ -219,6 +289,11 @@ if __name__ == '__main__':
@@ -219,6 +289,11 @@ if __name__ == '__main__':
|
|
|
|
|
|
|
|
|
|
#将文件夹移动到工作目录 |
|
|
|
|
shutil.move(os.path.join(needBuildDir,pid),os.path.join(workdir,pid)) |
|
|
|
|
|
|
|
|
|
res = getXmps(pid) |
|
|
|
|
if res == False: |
|
|
|
|
break |
|
|
|
|
|
|
|
|
|
#执行建模流程,建模中的流程 |
|
|
|
|
try: |
|
|
|
|
requests.post(url, data={'id': pid,'status':4000}) |
|
|
|
|
@ -226,6 +301,7 @@ if __name__ == '__main__':
@@ -226,6 +301,7 @@ if __name__ == '__main__':
|
|
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} pid:{pid} - 状态变更失败 - {e}') |
|
|
|
|
#continue |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main(pid,headsCounts) |
|
|
|
|
except Exception as e: |
|
|
|
|
print(f'{time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())} 建模任务循环异常 - {e}') |
|
|
|
|
|