小调整代码格式
This commit is contained in:
parent
32f73eef8a
commit
bfc45b4d27
@ -198,7 +198,12 @@ class ImagePreprocessor:
|
|||||||
return self.gps_points
|
return self.gps_points
|
||||||
|
|
||||||
def divide_grids(self) -> Tuple[Dict[tuple, pd.DataFrame], Dict[tuple, tuple]]:
|
def divide_grids(self) -> Tuple[Dict[tuple, pd.DataFrame], Dict[tuple, tuple]]:
|
||||||
"""划分网格"""
|
"""划分网格
|
||||||
|
Returns:
|
||||||
|
tuple: (grid_points, translations)
|
||||||
|
- grid_points: 网格点数据字典
|
||||||
|
- translations: 网格平移量字典
|
||||||
|
"""
|
||||||
self.logger.info(f"开始划分网格 (重叠率: {self.config.grid_overlap})")
|
self.logger.info(f"开始划分网格 (重叠率: {self.config.grid_overlap})")
|
||||||
grid_divider = GridDivider(
|
grid_divider = GridDivider(
|
||||||
overlap=self.config.grid_overlap,
|
overlap=self.config.grid_overlap,
|
||||||
@ -208,8 +213,6 @@ class ImagePreprocessor:
|
|||||||
self.gps_points, grid_size=self.config.grid_size
|
self.gps_points, grid_size=self.config.grid_size
|
||||||
)
|
)
|
||||||
grid_points = grid_divider.assign_to_grids(self.gps_points, grids)
|
grid_points = grid_divider.assign_to_grids(self.gps_points, grids)
|
||||||
|
|
||||||
# -1是因为包含了grid_divider
|
|
||||||
self.logger.info(f"成功划分为 {len(grid_points)} 个网格")
|
self.logger.info(f"成功划分为 {len(grid_points)} 个网格")
|
||||||
|
|
||||||
return grid_points, translations
|
return grid_points, translations
|
||||||
@ -219,37 +222,37 @@ class ImagePreprocessor:
|
|||||||
self.logger.info("开始复制图像文件")
|
self.logger.info("开始复制图像文件")
|
||||||
|
|
||||||
for grid_id, points in grid_points.items():
|
for grid_id, points in grid_points.items():
|
||||||
|
|
||||||
output_dir = os.path.join(
|
output_dir = os.path.join(
|
||||||
self.config.output_dir, f"grid_{grid_id[0]}_{grid_id[1]}", "project", "images"
|
self.config.output_dir, f"grid_{grid_id[0]}_{grid_id[1]}", "project", "images"
|
||||||
)
|
)
|
||||||
|
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
|
|
||||||
for point in tqdm(points, desc=f"复制网格 {grid_id} 的图像"):
|
for point in tqdm(points, desc=f"复制网格 ({grid_id[0]},{grid_id[1]}) 的图像"):
|
||||||
src = os.path.join(self.config.image_dir, point["file"])
|
src = os.path.join(self.config.image_dir, point["file"])
|
||||||
dst = os.path.join(output_dir, point["file"])
|
dst = os.path.join(output_dir, point["file"])
|
||||||
shutil.copy(src, dst)
|
shutil.copy(src, dst)
|
||||||
self.logger.info(f"网格 {grid_id} 包含 {len(points)} 张图像")
|
self.logger.info(
|
||||||
|
f"网格 ({grid_id[0]},{grid_id[1]}) 包含 {len(points)} 张图像")
|
||||||
|
|
||||||
def merge_tif(self, grid_points: Dict[int, pd.DataFrame]):
|
def merge_tif(self, grid_points: Dict[tuple, pd.DataFrame]):
|
||||||
"""合并所有网格的影像产品"""
|
"""合并所有网格的影像产品"""
|
||||||
self.logger.info("开始合并所有影像产品")
|
self.logger.info("开始合并所有影像产品")
|
||||||
merger = MergeTif(self.config.output_dir)
|
merger = MergeTif(self.config.output_dir)
|
||||||
merger.merge_all_tifs(grid_points)
|
merger.merge_all_tifs(grid_points)
|
||||||
|
|
||||||
|
def merge_ply(self, grid_points: Dict[tuple, pd.DataFrame]):
|
||||||
|
"""合并所有网格的PLY点云"""
|
||||||
|
self.logger.info("开始合并PLY点云")
|
||||||
|
merger = MergePly(self.config.output_dir)
|
||||||
|
merger.merge_grid_laz(grid_points)
|
||||||
|
|
||||||
def merge_obj(self, grid_points: Dict[tuple, pd.DataFrame], translations: Dict[tuple, tuple]):
|
def merge_obj(self, grid_points: Dict[tuple, pd.DataFrame], translations: Dict[tuple, tuple]):
|
||||||
"""合并所有网格的OBJ模型"""
|
"""合并所有网格的OBJ模型"""
|
||||||
self.logger.info("开始合并OBJ模型")
|
self.logger.info("开始合并OBJ模型")
|
||||||
merger = MergeObj(self.config.output_dir)
|
merger = MergeObj(self.config.output_dir)
|
||||||
merger.merge_grid_obj(grid_points, translations)
|
merger.merge_grid_obj(grid_points, translations)
|
||||||
|
|
||||||
def merge_ply(self, grid_points: Dict[int, pd.DataFrame]):
|
|
||||||
"""合并所有网格的PLY点云"""
|
|
||||||
self.logger.info("开始合并PLY点云")
|
|
||||||
merger = MergePly(self.config.output_dir)
|
|
||||||
merger.merge_grid_laz(grid_points)
|
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
"""执行完整的预处理流程"""
|
"""执行完整的预处理流程"""
|
||||||
try:
|
try:
|
||||||
|
@ -232,7 +232,8 @@ class ImagePreprocessor:
|
|||||||
src = os.path.join(self.config.image_dir, point["file"])
|
src = os.path.join(self.config.image_dir, point["file"])
|
||||||
dst = os.path.join(output_dir, point["file"])
|
dst = os.path.join(output_dir, point["file"])
|
||||||
shutil.copy(src, dst)
|
shutil.copy(src, dst)
|
||||||
self.logger.info(f"网格 ({grid_id[0]},{grid_id[1]}) 包含 {len(points)} 张图像")
|
self.logger.info(
|
||||||
|
f"网格 ({grid_id[0]},{grid_id[1]}) 包含 {len(points)} 张图像")
|
||||||
|
|
||||||
def merge_tif(self, grid_points: Dict[tuple, pd.DataFrame]):
|
def merge_tif(self, grid_points: Dict[tuple, pd.DataFrame]):
|
||||||
"""合并所有网格的影像产品"""
|
"""合并所有网格的影像产品"""
|
||||||
@ -240,18 +241,18 @@ class ImagePreprocessor:
|
|||||||
merger = MergeTif(self.config.output_dir)
|
merger = MergeTif(self.config.output_dir)
|
||||||
merger.merge_all_tifs(grid_points)
|
merger.merge_all_tifs(grid_points)
|
||||||
|
|
||||||
def merge_obj(self, grid_points: Dict[tuple, pd.DataFrame], translations: Dict[tuple, tuple]):
|
|
||||||
"""合并所有网格的OBJ模型"""
|
|
||||||
self.logger.info("开始合并OBJ模型")
|
|
||||||
merger = MergeObj(self.config.output_dir)
|
|
||||||
merger.merge_grid_obj(grid_points, translations)
|
|
||||||
|
|
||||||
def merge_ply(self, grid_points: Dict[tuple, pd.DataFrame]):
|
def merge_ply(self, grid_points: Dict[tuple, pd.DataFrame]):
|
||||||
"""合并所有网格的PLY点云"""
|
"""合并所有网格的PLY点云"""
|
||||||
self.logger.info("开始合并PLY点云")
|
self.logger.info("开始合并PLY点云")
|
||||||
merger = MergePly(self.config.output_dir)
|
merger = MergePly(self.config.output_dir)
|
||||||
merger.merge_grid_laz(grid_points)
|
merger.merge_grid_laz(grid_points)
|
||||||
|
|
||||||
|
def merge_obj(self, grid_points: Dict[tuple, pd.DataFrame], translations: Dict[tuple, tuple]):
|
||||||
|
"""合并所有网格的OBJ模型"""
|
||||||
|
self.logger.info("开始合并OBJ模型")
|
||||||
|
merger = MergeObj(self.config.output_dir)
|
||||||
|
merger.merge_grid_obj(grid_points, translations)
|
||||||
|
|
||||||
def process(self):
|
def process(self):
|
||||||
"""执行完整的预处理流程"""
|
"""执行完整的预处理流程"""
|
||||||
try:
|
try:
|
||||||
@ -292,7 +293,7 @@ if __name__ == "__main__":
|
|||||||
filter_dense_distance_threshold=10,
|
filter_dense_distance_threshold=10,
|
||||||
filter_time_threshold=timedelta(minutes=5),
|
filter_time_threshold=timedelta(minutes=5),
|
||||||
|
|
||||||
grid_size=300,
|
grid_size=500,
|
||||||
grid_overlap=0.1,
|
grid_overlap=0.1,
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user