修改odm运行参数
This commit is contained in:
parent
f6d6f112c9
commit
d05f278d79
2
main.py
2
main.py
@ -1,6 +1,6 @@
|
|||||||
import argparse
|
import argparse
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from odm_preprocess_fast import PreprocessConfig, ImagePreprocessor
|
from odm_preprocess import PreprocessConfig, ImagePreprocessor
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(description='ODM预处理工具')
|
parser = argparse.ArgumentParser(description='ODM预处理工具')
|
||||||
|
@ -75,9 +75,9 @@ class ConvertOBJ:
|
|||||||
self.logger.info(f"开始转换网格 {grid_id} 的OBJ文件")
|
self.logger.info(f"开始转换网格 {grid_id} 的OBJ文件")
|
||||||
output_osgb = os.path.join(texturing_dir, "Tile.osgb")
|
output_osgb = os.path.join(texturing_dir, "Tile.osgb")
|
||||||
cmd = (
|
cmd = (
|
||||||
f"osgconv {obj_file} {output_osgb} "
|
f"osgconv {modified_obj} {output_osgb} "
|
||||||
f"--compressed --smooth --fix-transparency "
|
f"--compressed --smooth --fix-transparency "
|
||||||
f"-o 0,1,0-0,0,-1"
|
# f"-o -90-1,0,0"
|
||||||
)
|
)
|
||||||
self.logger.info(f"执行osgconv命令:{cmd}")
|
self.logger.info(f"执行osgconv命令:{cmd}")
|
||||||
|
|
||||||
@ -143,31 +143,6 @@ class ConvertOBJ:
|
|||||||
<ModelMetadata version="1">
|
<ModelMetadata version="1">
|
||||||
<SRS>EPSG:4326</SRS>
|
<SRS>EPSG:4326</SRS>
|
||||||
<SRSOrigin>{self.center_lon},{self.center_lat},0.000000</SRSOrigin>
|
<SRSOrigin>{self.center_lon},{self.center_lat},0.000000</SRSOrigin>
|
||||||
<TileStructure>
|
|
||||||
<RootNode>
|
|
||||||
<BoundingBox>
|
|
||||||
<MinLat>{min([t['bounds']['min_lat'] for t in tile_infos])}</MinLat>
|
|
||||||
<MaxLat>{max([t['bounds']['max_lat'] for t in tile_infos])}</MaxLat>
|
|
||||||
<MinLon>{min([t['bounds']['min_lon'] for t in tile_infos])}</MinLon>
|
|
||||||
<MaxLon>{max([t['bounds']['max_lon'] for t in tile_infos])}</MaxLon>
|
|
||||||
</BoundingBox>
|
|
||||||
<Tiles>"""
|
|
||||||
|
|
||||||
for tile in tile_infos:
|
|
||||||
metadata_content += f"""
|
|
||||||
<Tile id="{tile['id']}">
|
|
||||||
<BoundingBox>
|
|
||||||
<MinLat>{tile['bounds']['min_lat']}</MinLat>
|
|
||||||
<MaxLat>{tile['bounds']['max_lat']}</MaxLat>
|
|
||||||
<MinLon>{tile['bounds']['min_lon']}</MinLon>
|
|
||||||
<MaxLon>{tile['bounds']['max_lon']}</MaxLon>
|
|
||||||
</BoundingBox>
|
|
||||||
</Tile>"""
|
|
||||||
|
|
||||||
metadata_content += """
|
|
||||||
</Tiles>
|
|
||||||
</RootNode>
|
|
||||||
</TileStructure>
|
|
||||||
<Texture>
|
<Texture>
|
||||||
<ColorSource>Visible</ColorSource>
|
<ColorSource>Visible</ColorSource>
|
||||||
</Texture>
|
</Texture>
|
||||||
@ -214,7 +189,7 @@ class ConvertOBJ:
|
|||||||
x = float(parts[1]) + (east_offset - self.min_east)
|
x = float(parts[1]) + (east_offset - self.min_east)
|
||||||
y = float(parts[2]) + (north_offset - self.min_north)
|
y = float(parts[2]) + (north_offset - self.min_north)
|
||||||
z = float(parts[3])
|
z = float(parts[3])
|
||||||
f_out.write(f'v {x:.6f} {y:.6f} {z:.6f}\n')
|
f_out.write(f'v {x:.6f} {z:.6f} {y:.6f}\n')
|
||||||
else:
|
else:
|
||||||
# 其他行直接写入
|
# 其他行直接写入
|
||||||
f_out.write(line)
|
f_out.write(line)
|
||||||
|
@ -125,16 +125,14 @@ class ODMProcessMonitor:
|
|||||||
|
|
||||||
def run_odm_with_monitor(self, grid_dir: str, grid_id: tuple, produce_dem: bool = False) -> Tuple[bool, str]:
|
def run_odm_with_monitor(self, grid_dir: str, grid_id: tuple, produce_dem: bool = False) -> Tuple[bool, str]:
|
||||||
"""运行ODM命令"""
|
"""运行ODM命令"""
|
||||||
# if produce_dem and self.mode == "快拼模式":
|
|
||||||
# self.logger.error("快拼模式下无法生成DEM,请调整生产参数")
|
|
||||||
# return False, "快拼模式下无法生成DEM,请调整生产参数"
|
|
||||||
|
|
||||||
self.logger.info(f"开始处理网格 ({grid_id[0]},{grid_id[1]})")
|
self.logger.info(f"开始处理网格 ({grid_id[0]},{grid_id[1]})")
|
||||||
success = False
|
success = False
|
||||||
error_msg = ""
|
error_msg = ""
|
||||||
max_retries = 3
|
max_retries = 3
|
||||||
current_try = 0
|
current_try = 0
|
||||||
use_lowest_quality = True # 初始使用lowest quality
|
|
||||||
|
# 根据模式设置是否使用lowest quality
|
||||||
|
use_lowest_quality = self.mode == "快拼模式"
|
||||||
|
|
||||||
while current_try < max_retries:
|
while current_try < max_retries:
|
||||||
current_try += 1
|
current_try += 1
|
||||||
@ -151,6 +149,10 @@ class ODMProcessMonitor:
|
|||||||
f"--project-path /datasets project "
|
f"--project-path /datasets project "
|
||||||
f"--max-concurrency 15 "
|
f"--max-concurrency 15 "
|
||||||
f"--force-gps "
|
f"--force-gps "
|
||||||
|
f"--use-exif "
|
||||||
|
f"--use-hybrid-bundle-adjustment "
|
||||||
|
f"--optimize-disk-space "
|
||||||
|
# f"--feature-quality ultra "
|
||||||
)
|
)
|
||||||
|
|
||||||
# 根据是否使用lowest quality添加参数
|
# 根据是否使用lowest quality添加参数
|
||||||
@ -170,10 +172,10 @@ class ODMProcessMonitor:
|
|||||||
#f"--fast-orthophoto "
|
#f"--fast-orthophoto "
|
||||||
f"--skip-3dmodel "
|
f"--skip-3dmodel "
|
||||||
)
|
)
|
||||||
elif self.mode == "三维模式":
|
# elif self.mode == "三维模式":
|
||||||
docker_command += (
|
# docker_command += (
|
||||||
f"--skip-orthophoto "
|
# f"--skip-orthophoto "
|
||||||
)
|
# )
|
||||||
|
|
||||||
docker_command += "--rerun-all"
|
docker_command += "--rerun-all"
|
||||||
self.logger.info(docker_command)
|
self.logger.info(docker_command)
|
||||||
@ -223,7 +225,7 @@ class ODMProcessMonitor:
|
|||||||
raise NotOverlapError
|
raise NotOverlapError
|
||||||
|
|
||||||
except NotOverlapError:
|
except NotOverlapError:
|
||||||
if use_lowest_quality:
|
if use_lowest_quality and self.mode == "快拼模式":
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
"检测到not overlap错误,移除lowest quality参数后重试")
|
"检测到not overlap错误,移除lowest quality参数后重试")
|
||||||
use_lowest_quality = False
|
use_lowest_quality = False
|
||||||
|
Loading…
Reference in New Issue
Block a user