ODM_pro/show_GPS.py
2024-12-17 22:09:47 +08:00

45 lines
1.4 KiB
Python

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()