修改obj的法向量,subprocess.Popen
This commit is contained in:
parent
30a451a19b
commit
105d113e4b
@ -147,6 +147,14 @@ class ConvertOBJ:
|
|||||||
y = float(parts[2]) + (north_offset - self.ref_north)
|
y = float(parts[2]) + (north_offset - self.ref_north)
|
||||||
z = float(parts[3])
|
z = float(parts[3])
|
||||||
f_out.write(f'v {x:.6f} {z:.6f} {-y:.6f}\n')
|
f_out.write(f'v {x:.6f} {z:.6f} {-y:.6f}\n')
|
||||||
|
elif line.startswith('vn '): # 处理法线向量
|
||||||
|
parts = line.split()
|
||||||
|
nx = float(parts[1])
|
||||||
|
ny = float(parts[2])
|
||||||
|
nz = float(parts[3])
|
||||||
|
# 同步反转法线的 Y 轴
|
||||||
|
new_line = f"vn {nx} {nz} {-ny}\n"
|
||||||
|
f_out.write(new_line)
|
||||||
else:
|
else:
|
||||||
# 其他行直接写入
|
# 其他行直接写入
|
||||||
f_out.write(line)
|
f_out.write(line)
|
||||||
|
@ -40,8 +40,10 @@ class ODMProcessMonitor:
|
|||||||
elif self.mode == "三维模式":
|
elif self.mode == "三维模式":
|
||||||
# 检查点云和实景三维
|
# 检查点云和实景三维
|
||||||
if not all([
|
if not all([
|
||||||
os.path.exists(os.path.join(project_dir, 'odm_georeferencing', 'odm_georeferenced_model.laz')),
|
os.path.exists(os.path.join(
|
||||||
os.path.exists(os.path.join(project_dir, 'odm_texturing', 'odm_textured_model_geo.obj'))
|
project_dir, 'odm_georeferencing', 'odm_georeferenced_model.laz')),
|
||||||
|
os.path.exists(os.path.join(
|
||||||
|
project_dir, 'odm_texturing', 'odm_textured_model_geo.obj'))
|
||||||
]):
|
]):
|
||||||
self.logger.error("点云或实景三维文件夹未生成")
|
self.logger.error("点云或实景三维文件夹未生成")
|
||||||
return False
|
return False
|
||||||
@ -51,8 +53,10 @@ class ODMProcessMonitor:
|
|||||||
elif self.mode == "重建模式":
|
elif self.mode == "重建模式":
|
||||||
# 检查所有产品
|
# 检查所有产品
|
||||||
if not all([
|
if not all([
|
||||||
os.path.exists(os.path.join(project_dir, 'odm_georeferencing', 'odm_georeferenced_model.laz')),
|
os.path.exists(os.path.join(
|
||||||
os.path.exists(os.path.join(project_dir, 'odm_texturing', 'odm_textured_model_geo.obj'))
|
project_dir, 'odm_georeferencing', 'odm_georeferenced_model.laz')),
|
||||||
|
os.path.exists(os.path.join(
|
||||||
|
project_dir, 'odm_texturing', 'odm_textured_model_geo.obj'))
|
||||||
]):
|
]):
|
||||||
self.logger.error("部分必要的文件夹未生成")
|
self.logger.error("部分必要的文件夹未生成")
|
||||||
return False
|
return False
|
||||||
@ -68,7 +72,8 @@ class ODMProcessMonitor:
|
|||||||
# TODO 正射影像怎么检查最好
|
# TODO 正射影像怎么检查最好
|
||||||
def _check_orthophoto(self, project_dir: str) -> bool:
|
def _check_orthophoto(self, project_dir: str) -> bool:
|
||||||
"""检查正射影像的质量"""
|
"""检查正射影像的质量"""
|
||||||
ortho_path = os.path.join(project_dir, 'odm_orthophoto', 'odm_orthophoto.original.tif')
|
ortho_path = os.path.join(
|
||||||
|
project_dir, 'odm_orthophoto', 'odm_orthophoto.original.tif')
|
||||||
|
|
||||||
if not os.path.exists(ortho_path):
|
if not os.path.exists(ortho_path):
|
||||||
self.logger.error("正射影像文件未生成")
|
self.logger.error("正射影像文件未生成")
|
||||||
@ -150,8 +155,8 @@ class ODMProcessMonitor:
|
|||||||
f"--max-concurrency 15 "
|
f"--max-concurrency 15 "
|
||||||
f"--force-gps "
|
f"--force-gps "
|
||||||
f"--use-exif "
|
f"--use-exif "
|
||||||
f"--use-hybrid-bundle-adjustment "
|
# f"--use-hybrid-bundle-adjustment "
|
||||||
f"--optimize-disk-space "
|
# f"--optimize-disk-space "
|
||||||
# f"--feature-quality ultra "
|
# f"--feature-quality ultra "
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -180,11 +185,19 @@ class ODMProcessMonitor:
|
|||||||
docker_command += "--rerun-all"
|
docker_command += "--rerun-all"
|
||||||
self.logger.info(docker_command)
|
self.logger.info(docker_command)
|
||||||
|
|
||||||
result = subprocess.run(
|
process = subprocess.Popen(
|
||||||
docker_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
docker_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||||
# TODO 关闭process,内存堆积
|
logging.info(f"进程{process.pid}开始执行")
|
||||||
stdout, stderr = result.stdout.decode(
|
stdout, stderr = process.communicate()
|
||||||
'utf-8'), result.stderr.decode('utf-8')
|
stdout = stdout.decode('utf-8')
|
||||||
|
stderr = stderr.decode('utf-8')
|
||||||
|
# 关闭process,防止内存堆积
|
||||||
|
process.terminate()
|
||||||
|
return_code = process.poll() # 获取进程返回码,如果返回 None 说明进程仍在运行
|
||||||
|
if return_code is None:
|
||||||
|
logging.info(f"进程{process.pid}仍在运行")
|
||||||
|
else:
|
||||||
|
logging.info(f"进程{process.pid}已被关闭,返回码:{return_code}.")
|
||||||
|
|
||||||
stdout_lines = stdout.strip().split('\n')
|
stdout_lines = stdout.strip().split('\n')
|
||||||
last_lines = '\n'.join(
|
last_lines = '\n'.join(
|
||||||
|
Loading…
Reference in New Issue
Block a user