修改selector

This commit is contained in:
龙澳 2025-01-07 10:37:10 +08:00
parent 7a3e5e06c9
commit 8ae2ec610c
2 changed files with 13 additions and 12 deletions

View File

@ -141,14 +141,15 @@ class GPSSelector:
# 创建输出目录
os.makedirs(self.output_dir, exist_ok=True)
removed_dir = os.path.join(self.output_dir, "removed_images")
os.makedirs(removed_dir, exist_ok=True)
# 移动被删除的图像
for img_name in self.selected_points:
# 获取所有保留的图片文件名
remaining_files = self.gps_points['file'].tolist()
# 移动保留的图片到输出目录
for img_name in remaining_files:
src = os.path.join(self.image_dir, img_name)
dst = os.path.join(removed_dir, img_name)
shutil.move(src, dst)
dst = os.path.join(self.output_dir, img_name)
shutil.copy2(src, dst) # 使用copy2保留文件的元数据
# 保存剩余点的信息
self.gps_points.to_csv(
@ -156,8 +157,8 @@ class GPSSelector:
index=False
)
print(f"移动 {len(self.selected_points)} 张图片{removed_dir}")
print(f"保留 {len(self.gps_points)} 个点")
print(f"选择删除 {len(self.selected_points)} 张图片")
print(f"已复制 {len(remaining_files)} 张保留的图片到 {self.output_dir}")
def run(self):
"""运行选择器"""
@ -229,7 +230,7 @@ class GPSSelector:
if __name__ == "__main__":
# 使用示例
selector = GPSSelector(
image_dir=r"C:\datasets\134\code\images",
output_dir=r"C:\datasets\ODM_output\134"
image_dir=r"G:\error_data\20240930091614\project\images",
output_dir=r"C:\datasets\ODM_output\error1_L"
)
selector.run()

View File

@ -286,8 +286,8 @@ class ImagePreprocessor:
if __name__ == "__main__":
# 创建配置
config = PreprocessConfig(
image_dir=r"E:\datasets\UAV\1619\project\images",
output_dir=r"G:\ODM_output\1619",
image_dir=r"G:\test_data\error1_L",
output_dir=r"G:\ODM_output\error1_L",
cluster_eps=0.01,
cluster_min_samples=5,