UAV/utils/command_runner.py

33 lines
1.1 KiB
Python
Raw Normal View History

2024-12-23 11:31:20 +08:00
import os
import logging
from typing import Dict
import pandas as pd
from utils.odm_monitor import ODMProcessMonitor
class CommandRunner:
"""执行网格处理命令的类"""
2024-12-26 11:20:55 +08:00
def __init__(self, output_dir: str, mode: str = "快拼模式"):
2024-12-23 11:31:20 +08:00
self.output_dir = output_dir
self.logger = logging.getLogger('UAV_Preprocess.CommandRunner')
2024-12-26 11:20:55 +08:00
self.monitor = ODMProcessMonitor(mode=mode)
2024-12-23 11:31:20 +08:00
self.mode = mode
2024-12-26 11:20:55 +08:00
def run_grid_commands(self, grid_points: Dict[int, pd.DataFrame]):
"""处理所有网格"""
self.logger.info("开始执行网格处理")
for grid_idx in grid_points.keys():
grid_dir = os.path.abspath(os.path.join(
self.output_dir, f'grid_{grid_idx + 1}'
))
2024-12-23 11:31:20 +08:00
success, error_msg = self.monitor.run_odm_with_monitor(
2024-12-25 14:28:01 +08:00
grid_dir=grid_dir,
grid_idx=grid_idx,
fast_mode=(self.mode == "快拼模式")
)
2024-12-23 11:31:20 +08:00
if not success:
2024-12-26 11:20:55 +08:00
raise Exception(f"网格 {grid_idx + 1} 处理失败: {error_msg}")