From e9cd12b2f689633758cbdae807d5e5db318c1b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BE=99=E6=BE=B3?= Date: Wed, 18 Dec 2024 21:07:47 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=84=E8=8C=83=E4=BB=A3=E7=A0=81=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- odm_preprocess.py | 56 ++++++++++-------- .../__pycache__/gps_extractor.cpython-39.pyc | Bin 1625 -> 3040 bytes .../__pycache__/gps_filter.cpython-39.pyc | Bin 4692 -> 5292 bytes .../__pycache__/grid_divider.cpython-39.pyc | Bin 1955 -> 3065 bytes .../__pycache__/time_filter.cpython-39.pyc | Bin 0 -> 2384 bytes preprocess/command_runner.py | 21 +++---- 6 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 preprocess/__pycache__/time_filter.cpython-39.pyc diff --git a/odm_preprocess.py b/odm_preprocess.py index 37faaf6..7d6ee2f 100644 --- a/odm_preprocess.py +++ b/odm_preprocess.py @@ -46,7 +46,7 @@ class ImagePreprocessor: self.gps_points = extractor.extract_all_gps() self.logger.info(f"成功提取 {len(self.gps_points)} 个GPS点") return self.gps_points - + def time_filter(self) -> pd.DataFrame: """时间过滤""" self.logger.info("开始时间过滤") @@ -64,8 +64,8 @@ class ImagePreprocessor: self.logger.info("开始过滤GPS点") filter = GPSFilter(self.config.output_dir) - self.logger.info(f"开始过滤孤立点 (距离阈值: {self.config.filter_distance_threshold}, 最小邻居数: { - self.config.filter_min_neighbors})") + self.logger.info( + f"开始过滤孤立点(距离阈值: {self.config.filter_distance_threshold}, 最小邻居数: {self.config.filter_min_neighbors})") self.gps_points = filter.filter_isolated_points( self.gps_points, self.config.filter_distance_threshold, @@ -73,8 +73,8 @@ class ImagePreprocessor: ) self.logger.info(f"孤立点过滤后剩余 {len(self.gps_points)} 个GPS点") - self.logger.info(f"开始过滤密集点 (网格大小: {self.config.filter_grid_size}, 距离阈值: { - self.config.filter_dense_distance_threshold})") + self.logger.info( + f"开始过滤密集点(网格大小: {self.config.filter_grid_size}, 距离阈值: {self.config.filter_dense_distance_threshold})") self.gps_points = filter.filter_dense_points( self.gps_points, grid_size=self.config.filter_grid_size, @@ -90,7 +90,8 @@ class ImagePreprocessor: self.logger.info(f"开始划分网格 (重叠率: {self.config.grid_overlap})") grid_divider = GridDivider(overlap=self.config.grid_overlap) - grids = grid_divider.divide_grids(self.gps_points, grid_size=self.config.grid_size) + grids = grid_divider.divide_grids( + self.gps_points, grid_size=self.config.grid_size) grid_points = grid_divider.assign_to_grids(self.gps_points, grids) self.logger.info(f"成功划分为 {len(grid_points)} 个网格") return grid_points @@ -104,9 +105,11 @@ class ImagePreprocessor: for grid_idx, points in grid_points.items(): if self.config.enable_grid_division: - output_dir = os.path.join(self.config.output_dir, f'grid_{grid_idx + 1}', 'project', 'images') + output_dir = os.path.join( + self.config.output_dir, f'grid_{grid_idx + 1}', 'project', 'images') else: - output_dir = os.path.join(self.config.output_dir, 'project', 'images') + output_dir = os.path.join( + self.config.output_dir, 'project', 'images') os.makedirs(output_dir, exist_ok=True) @@ -131,21 +134,22 @@ class ImagePreprocessor: # 创建一个新的图形 plt.figure(figsize=(20, 16)) - + # 绘制所有原始点 - plt.scatter(original_points_df['lon'], - original_points_df['lat'], - color='blue', - label="Original Points", - alpha=0.6) - + plt.scatter(original_points_df['lon'], + original_points_df['lat'], + color='blue', + label="Original Points", + alpha=0.6) + # 绘制被过滤的点 - filtered_points_df = original_points_df[original_points_df['file'].isin(filtered_files)] - plt.scatter(filtered_points_df['lon'], - filtered_points_df['lat'], - color="red", - label="Filtered Points", - alpha=0.6) + filtered_points_df = original_points_df[original_points_df['file'].isin( + filtered_files)] + plt.scatter(filtered_points_df['lon'], + filtered_points_df['lat'], + color="red", + label="Filtered Points", + alpha=0.6) # 设置图形属性 plt.title("GPS Coordinates of Images", fontsize=14) @@ -153,7 +157,7 @@ class ImagePreprocessor: plt.ylabel("Latitude", fontsize=12) plt.grid(True) plt.legend() - + # 保存图形 plt.savefig(os.path.join(self.config.output_dir, 'filter_GPS.png')) plt.close() @@ -161,7 +165,7 @@ class ImagePreprocessor: def process(self): """执行完整的预处理流程""" - try: + try: self.extract_gps() self.time_filter() self.filter_points() @@ -170,7 +174,7 @@ class ImagePreprocessor: self.visualize_results() self.logger.info("预处理任务完成") self.command_runner.run_grid_commands( - grid_points, + grid_points, self.config.enable_grid_division ) except Exception as e: @@ -181,8 +185,8 @@ class ImagePreprocessor: if __name__ == '__main__': # 创建配置 config = PreprocessConfig( - image_dir=r'C:\datasets\1815\images', - output_dir=r'C:\datasets\1815\output', + image_dir=r'E:\datasets\UAV\1815', + output_dir=r'E:\datasets\UAV\1815\output', filter_grid_size=0.001, filter_dense_distance_threshold=10, filter_distance_threshold=0.001, diff --git a/preprocess/__pycache__/gps_extractor.cpython-39.pyc b/preprocess/__pycache__/gps_extractor.cpython-39.pyc index b4369dc5633de13bd7bf592af909af666de7404d..e6cb3337cd29fca1eca092bd875088ab106983fb 100644 GIT binary patch literal 3040 zcmai0>u(#!5#PPtdr{OQij&%Kk}^#dfUTk$0onpWP^73G*F~%v5Sqt9&Edj5(I=2R zX75&8{~-ULf#X{`}?Y@TtWn%~Ik%cl%^%Hfk>H}d3FZSc0?pIJW z`V1%WG;n?5P(d6`P;jaVc9A&T*9Q(RP{#n;5avY!v?(lMgWM7YF$SY8ir{)YEgnC$ zc0%oLkleHh(yZF6|Uy6YRf2tVF0@0q1Nf)-dtMy>bJ?(i|2PZK*_c$f^ zz6fhvBu7+VW~~|cW&8a<_5ZMT?1dB0Y~KE0>-TwP_1AChtbdYyu)cNkz0KQyZQnQZ z;`~f~enymLemp;Oa(-rUq0A+wTWUqIY$94x0~QksKedmYt@ywS8?gG~E|^@<`*IkX zo{S*Xa=<+R1|wV%VVX8gi*$c5_Nwp6e~c?O6^xf)Kh|g-4#@tF7HeIWXe%630lrzn zy1LK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)WIxgU!6%>%J!Ybt_{e%tdm+2)>}dHI+hAsqcB5t z5e?S$n86Y&4hH=ivB1u3&Zr~op(5fMY7+b&UtNBxaL&{y8a#B2sNkJ02GqXWise=m O+{1oq4A{_YoBsnwpwS8d diff --git a/preprocess/__pycache__/gps_filter.cpython-39.pyc b/preprocess/__pycache__/gps_filter.cpython-39.pyc index 2350bc0c469f9c5249ce205793d3023ef2446267..eb00f2b6d029b4f979ee85d7ce639f61c46730c7 100644 GIT binary patch literal 5292 zcmaKw{cjw_8OL{a_xAQ)eSRU>fud_l+n9od4GlDnLTFQ{3WO*DDvm^}%gx%k`w>@KL)@s_nsIc;9ps)qW+X2Bf&PrM?e6k!vSug41 zM$TYiotcZE&L~;q(Ok4uXXkA7UMv@XQsX9%9M*VbO3x)Y+o=s&OBh$%Hpqfxp)$Uw zSkC*!O4&o%dTQ%)!gUMOzVg>u(bK4PHCjbZ=PYM%og0U>oasiwS*BRdLf+!h!y58Y zZu1!0ZQjF^Jaw4mV!W4k@eFct-i@{N1+gc$?|h0tKGx7B<7`fsnq&B8Bf|ALhP=f!Ol54F zOmes66vxNBA^#PBvj6$VUvRbyw<;!AU5XuPb2S&z@j==4C;aDxuww{Ua9%jn(y$UIID>?R(In^?#5l7U*pBf z$gXF%KI350UDeLqyT+;>4G%30RSyQX;}pw9-*Hm(b@Z7U%dp9w&I*Ux9SW+EI^dT; zvXPWd-a&@5y6I~T=wObiC-k9f^+??cOH%7cOFgPehGeQ_qom6y*Y83b*L$Jah9M(r z1VdVLtdDARX)pKa)9%#jF|MPY=8MRf>K);RjM12LdY@L0OH;=CXeZ3tLs;Ckb90O5 z-kraA23tFS>5Zj#KU;kNaPxx;i?c_reSUiJ!zsQ}j{Pa)PuO2I2 z+>qCnXzQ04#Gn|yH*$WI0du0@`d6B%IFOOh9CWJqj2+UI6ABL=yN#=dD zAU_hY9XYeQw>Yfi2#%*)^79UAa&%UZE#=4e@O;4Vzo2$96kV7;h&y}p2V8+U-ENe< zH4vI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 diff --git a/preprocess/command_runner.py b/preprocess/command_runner.py index 2b8c9b1..207d888 100644 --- a/preprocess/command_runner.py +++ b/preprocess/command_runner.py @@ -4,13 +4,14 @@ import subprocess from typing import Dict import pandas as pd + class CommandRunner: """执行网格处理命令的类""" def __init__(self, output_dir: str): """ 初始化命令执行器 - + Args: output_dir: 输出目录路径 """ @@ -20,7 +21,7 @@ class CommandRunner: def run_grid_commands(self, grid_points: Dict[int, pd.DataFrame], enable_grid_division: bool = True): """ 为每个网格顺序运行指定命令 - + Args: grid_points: 网格点数据字典,键为网格索引,值为该网格的点数据 enable_grid_division: 是否启用网格划分 @@ -30,7 +31,7 @@ class CommandRunner: return self.logger.info("开始执行网格处理命令") - + # 顺序执行每个网格的命令 for grid_idx in grid_points.keys(): try: @@ -42,10 +43,10 @@ class CommandRunner: def _run_command(self, grid_idx: int): """ 执行单个网格的命令 - + Args: grid_idx: 网格索引 - + Raises: Exception: 当命令执行失败时抛出异常 """ @@ -55,7 +56,7 @@ class CommandRunner: command = f"docker run -ti --rm -v {grid_dir}:/datasets opendronemap/odm --project-path /datasets project --feature-quality lowest --force-gps" self.logger.info(f"执行命令: {command} 在目录: {grid_dir}") - + # 在指定目录下执行命令 process = subprocess.Popen( command, @@ -65,10 +66,10 @@ class CommandRunner: stderr=subprocess.PIPE, text=True ) - + # 获取命令输出 stdout, stderr = process.communicate() - + # 检查命令执行结果 if process.returncode == 0: self.logger.info(f"网格 {grid_idx + 1} 命令执行成功") @@ -83,7 +84,7 @@ class CommandRunner: f.write(f"\n错误日志:\n") f.write(f"{stderr}") raise Exception(f"命令执行失败: {stderr}") - + except Exception as e: self.logger.error(f"网格 {grid_idx + 1} 命令执行出错: {str(e)}") - raise \ No newline at end of file + raise