隔一个删一个

This commit is contained in:
龙澳 2025-01-17 15:36:32 +08:00
parent d6ccbb670b
commit 6e589d1193

View File

@ -187,6 +187,21 @@ class ImagePreprocessor:
self.visualizer.visualize_filter_step(
self.gps_points, previous_points, "3-Time Group Overlap")
def filter_alternate_images(self):
"""按时间顺序隔一个删一个图像来降低密度"""
previous_points = self.gps_points.copy()
# 按时间戳排序
self.gps_points = self.gps_points.sort_values('timestamp')
# 保留索引为偶数的行(即隔一个保留一个)
self.gps_points = self.gps_points.iloc[::2].reset_index(drop=True)
self.visualizer.visualize_filter_step(
self.gps_points, previous_points, "4-Alternate Images")
self.logger.info(f"交替过滤后剩余 {len(self.gps_points)} 个点")
def divide_grids(self) -> Tuple[Dict[tuple, pd.DataFrame], Dict[tuple, tuple]]:
"""划分网格
Returns:
@ -270,6 +285,7 @@ class ImagePreprocessor:
self.cluster()
self.filter_isolated_points()
self.filter_time_group_overlap()
self.filter_alternate_images()
grid_points, translations = self.divide_grids()
self.copy_images(grid_points)
self.logger.info("预处理任务完成")