From 37ce5c746f9f5de6de1e3fd2bc922c172a2e3543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E6=BE=B3?= Date: Sat, 21 Dec 2024 12:36:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E8=A7=86=E5=8C=96=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- odm_preprocess.py | 12 +++++++----- preprocess/command_runner.py | 5 +++-- preprocess/odm_monitor.py | 5 +++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/odm_preprocess.py b/odm_preprocess.py index d4605d2..65d39f8 100644 --- a/odm_preprocess.py +++ b/odm_preprocess.py @@ -47,7 +47,7 @@ class ImagePreprocessor: self.config = config self.logger = setup_logger(config.output_dir) self.gps_points = [] - self.command_runner = CommandRunner(config.output_dir) + self.command_runner = CommandRunner(config.output_dir, mode=config.mode) def extract_gps(self) -> pd.DataFrame: """提取GPS数据""" @@ -177,6 +177,7 @@ class ImagePreprocessor: filtered_points_df["lon"], filtered_points_df["lat"], color="red", + marker="x", label="Filtered Points", alpha=0.6, ) @@ -206,7 +207,6 @@ class ImagePreprocessor: self.command_runner.run_grid_commands( grid_points, self.config.enable_grid_division, - self.mode ) # TODO 拼图 except Exception as e: @@ -217,8 +217,8 @@ class ImagePreprocessor: if __name__ == "__main__": # 创建配置 config = PreprocessConfig( - image_dir=r"E:\datasets\UAV\1815\images", - output_dir=r"test", + image_dir=r"E:\datasets\UAV\283\project\images", + output_dir=r"E:\studio2\ODM_pro\test", cluster_eps=0.01, cluster_min_samples=5, @@ -230,13 +230,15 @@ if __name__ == "__main__": filter_dense_distance_threshold=10, filter_time_threshold=timedelta(minutes=5), - grid_overlap=0.05, + grid_overlap=0.03, grid_size=500, enable_filter=True, enable_grid_division=True, enable_visualization=True, enable_copy_images=True, + + mode="快拼模式", ) # 创建处理器并执行 diff --git a/preprocess/command_runner.py b/preprocess/command_runner.py index 8d3616b..6c12576 100644 --- a/preprocess/command_runner.py +++ b/preprocess/command_runner.py @@ -10,7 +10,7 @@ from preprocess.odm_monitor import ODMProcessMonitor class CommandRunner: """执行网格处理命令的类""" - def __init__(self, output_dir: str, max_retries: int = 3): + def __init__(self, output_dir: str, max_retries: int = 3, mode: str = "快拼模式"): """ 初始化命令执行器 i @@ -21,7 +21,8 @@ i self.output_dir = output_dir self.max_retries = max_retries self.logger = logging.getLogger('UAV_Preprocess.CommandRunner') - self.monitor = ODMProcessMonitor(max_retries=max_retries) + self.monitor = ODMProcessMonitor(max_retries=max_retries, mode=mode) + self.mode = mode def _run_command(self, grid_idx: int): """ diff --git a/preprocess/odm_monitor.py b/preprocess/odm_monitor.py index 9d7292a..33cdb0b 100644 --- a/preprocess/odm_monitor.py +++ b/preprocess/odm_monitor.py @@ -8,17 +8,19 @@ from typing import Optional, Tuple class ODMProcessMonitor: """ODM进程监控器""" - def __init__(self, max_retries: int = 3, check_interval: int = 300): + def __init__(self, max_retries: int = 3, check_interval: int = 300, mode: str = "快拼模式"): """ 初始化监控器 Args: max_retries: 最大重试次数 check_interval: 检查间隔(秒) + mode: 模式 """ self.max_retries = max_retries self.check_interval = check_interval self.logger = logging.getLogger('UAV_Preprocess.ODMMonitor') + self.mode = mode def _is_process_running(self, pid: int) -> bool: """检查进程是否在运行""" @@ -45,7 +47,6 @@ class ODMProcessMonitor: command: ODM命令 grid_dir: 网格目录 grid_idx: 网格索引 - Returns: Tuple[bool, str]: (是否成功, 错误信息) """