优化可视化内容
This commit is contained in:
parent
e9cd12b2f6
commit
9e092910ea
@ -185,7 +185,7 @@ class ImagePreprocessor:
|
||||
if __name__ == '__main__':
|
||||
# 创建配置
|
||||
config = PreprocessConfig(
|
||||
image_dir=r'E:\datasets\UAV\1815',
|
||||
image_dir=r'E:\datasets\UAV\1815\images',
|
||||
output_dir=r'E:\datasets\UAV\1815\output',
|
||||
filter_grid_size=0.001,
|
||||
filter_dense_distance_threshold=10,
|
||||
|
BIN
preprocess/__pycache__/command_runner.cpython-39.pyc
Normal file
BIN
preprocess/__pycache__/command_runner.cpython-39.pyc
Normal file
Binary file not shown.
BIN
preprocess/__pycache__/logger.cpython-39.pyc
Normal file
BIN
preprocess/__pycache__/logger.cpython-39.pyc
Normal file
Binary file not shown.
44
show_GPS.py
44
show_GPS.py
@ -1,44 +0,0 @@
|
||||
from gps_extractor import GPSExtractor
|
||||
from gps_filter import GPSFilter
|
||||
from grid_divider import GridDivider
|
||||
import os
|
||||
import pandas as pd
|
||||
import shutil
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
DATASET = r'C:\datasets\1815\output\grid_5\grid_5\images'
|
||||
IS_ORIGIN = True
|
||||
|
||||
if __name__ == '__main__':
|
||||
if IS_ORIGIN:
|
||||
extractor = GPSExtractor(DATASET)
|
||||
gps_points = extractor.extract_all_gps()
|
||||
else:
|
||||
# 提取九宫格中的GPS数据
|
||||
gps_points = []
|
||||
for subdir in os.listdir(DATASET):
|
||||
subdir_path = os.path.join(DATASET, subdir)
|
||||
if os.path.isdir(subdir_path):
|
||||
extractor = GPSExtractor(subdir_path)
|
||||
sub_gps_points = extractor.extract_all_gps()
|
||||
gps_points = gps_points + sub_gps_points
|
||||
print(len(sub_gps_points))
|
||||
|
||||
longitudes = [p['lon'] for p in gps_points]
|
||||
latitudes = [p['lat'] for p in gps_points]
|
||||
# 绘制散点图
|
||||
plt.figure(figsize=(10, 8))
|
||||
plt.scatter(longitudes, latitudes, color='blue', marker='o')
|
||||
|
||||
# 添加标记,显示每个点的图像文件名
|
||||
for i, image in enumerate(gps_points):
|
||||
plt.text(longitudes[i], latitudes[i], image['file'], fontsize=9, ha='right')
|
||||
|
||||
# 添加图表标签
|
||||
plt.title("GPS Coordinates of Images", fontsize=14)
|
||||
plt.xlabel("Longitude", fontsize=12)
|
||||
plt.ylabel("Latitude", fontsize=12)
|
||||
|
||||
# 显示图形
|
||||
plt.grid(True)
|
||||
plt.show()
|
55
tools/odm_pip_time.py
Normal file
55
tools/odm_pip_time.py
Normal file
@ -0,0 +1,55 @@
|
||||
from datetime import datetime
|
||||
import json
|
||||
|
||||
|
||||
def parse_args():
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description="ODM log time")
|
||||
|
||||
parser.add_argument(
|
||||
"--path", default=r"E:\datasets\UAV\1815\project\log.json")
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
def main(args):
|
||||
# 读取 JSON 文件
|
||||
with open(args.path, 'r') as file:
|
||||
data = json.load(file)
|
||||
|
||||
# 提取 "stages" 中每个步骤的开始时间和持续时间
|
||||
stage_timings = []
|
||||
for i, stage in enumerate(data.get("stages", [])):
|
||||
stage_name = stage.get("name", "Unnamed Stage")
|
||||
start_time = stage.get("startTime")
|
||||
|
||||
# 获取当前阶段的开始时间
|
||||
if start_time:
|
||||
start_dt = datetime.fromisoformat(start_time)
|
||||
|
||||
# 获取阶段的结束时间:可以是下一个阶段的开始时间,或当前阶段的 `endTime`(如果存在)
|
||||
if i + 1 < len(data["stages"]):
|
||||
end_time = data["stages"][i + 1].get("startTime")
|
||||
else:
|
||||
end_time = stage.get("endTime") or data.get("endTime")
|
||||
|
||||
if end_time:
|
||||
end_dt = datetime.fromisoformat(end_time)
|
||||
duration = (end_dt - start_dt).total_seconds()
|
||||
stage_timings.append((stage_name, duration))
|
||||
|
||||
# 输出每个阶段的持续时间,调整为对齐格式
|
||||
total_time = 0
|
||||
print(f"{'Stage Name':<25} {'Duration (seconds)':>15}")
|
||||
print("=" * 45)
|
||||
for stage_name, duration in stage_timings:
|
||||
print(f"{stage_name:<25} {duration:>15.2f}")
|
||||
total_time += duration
|
||||
|
||||
print('Total Time:', total_time)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
args = parse_args()
|
||||
|
||||
main(args)
|
51
tools/show_GPS.py
Normal file
51
tools/show_GPS.py
Normal file
@ -0,0 +1,51 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
from preprocess.gps_extractor import GPSExtractor
|
||||
|
||||
DATASET = r'E:\湖南省第二测绘院\11-06-项目移交文件(王辉给)\无人机二三维节点扩容生产影像\影像数据\1009'
|
||||
|
||||
if __name__ == '__main__':
|
||||
extractor = GPSExtractor(DATASET)
|
||||
gps_points = extractor.extract_all_gps()
|
||||
|
||||
# 创建两个子图
|
||||
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(20, 8))
|
||||
|
||||
# 左图:原始散点图
|
||||
ax1.scatter(gps_points['lon'], gps_points['lat'],
|
||||
color='blue', marker='o', label='GPS Points')
|
||||
ax1.set_title("GPS Coordinates of Images", fontsize=14)
|
||||
ax1.set_xlabel("Longitude", fontsize=12)
|
||||
ax1.set_ylabel("Latitude", fontsize=12)
|
||||
ax1.grid(True)
|
||||
ax1.legend()
|
||||
|
||||
# # 右图:按时间排序的轨迹图
|
||||
# gps_points_sorted = gps_points.sort_values('date')
|
||||
|
||||
# # 绘制飞行轨迹线
|
||||
# ax2.plot(gps_points_sorted['lon'][300:600], gps_points_sorted['lat'][300:600],
|
||||
# color='blue', linestyle='-', linewidth=1, alpha=0.6)
|
||||
|
||||
# # 绘制GPS点
|
||||
# ax2.scatter(gps_points_sorted['lon'][300:600], gps_points_sorted['lat'][300:600],
|
||||
# color='red', marker='o', s=30, label='GPS Points')
|
||||
|
||||
# 标记起点和终点
|
||||
# ax2.scatter(gps_points_sorted['lon'].iloc[0], gps_points_sorted['lat'].iloc[0],
|
||||
# color='green', marker='^', s=100, label='Start')
|
||||
# ax2.scatter(gps_points_sorted['lon'].iloc[-1], gps_points_sorted['lat'].iloc[-1],
|
||||
# color='purple', marker='s', s=100, label='End')
|
||||
|
||||
ax2.set_title("UAV Flight Trajectory", fontsize=14)
|
||||
ax2.set_xlabel("Longitude", fontsize=12)
|
||||
ax2.set_ylabel("Latitude", fontsize=12)
|
||||
ax2.grid(True)
|
||||
ax2.legend()
|
||||
|
||||
# 调整子图之间的间距
|
||||
plt.tight_layout()
|
||||
plt.show()
|
Loading…
Reference in New Issue
Block a user