fix: return to center
This commit is contained in:
@@ -27,6 +27,7 @@ class VisualizationManager:
|
||||
def __init__(self, window_title="Drone Autopilot Visualization"):
|
||||
self.window_title = window_title
|
||||
self.fig = None
|
||||
self.ax_drone_view = None
|
||||
self.ax_global_map = None
|
||||
self.ax_detection = None
|
||||
self.ax_matches = None
|
||||
@@ -43,6 +44,9 @@ class VisualizationManager:
|
||||
self.keypoints = []
|
||||
self.matches = []
|
||||
|
||||
# Данные для вида БПЛА
|
||||
self.drone_view_image = None
|
||||
|
||||
self._setup_window()
|
||||
|
||||
def _setup_window(self):
|
||||
@@ -54,11 +58,16 @@ class VisualizationManager:
|
||||
# Открываем окно на полный экран
|
||||
self.fig.canvas.manager.window.state('zoomed')
|
||||
|
||||
# Создаем сетку 2x2
|
||||
gs = self.fig.add_gridspec(2, 2, hspace=0.3, wspace=0.3)
|
||||
# Создаем сетку 2x2 с разными размерами колонок
|
||||
gs = self.fig.add_gridspec(2, 2, hspace=0.3, wspace=0.3, width_ratios=[1, 1])
|
||||
|
||||
# Глобальная карта (левый верхний угол, занимает 2x1)
|
||||
self.ax_global_map = self.fig.add_subplot(gs[0, :])
|
||||
# Вид БПЛА (левый верхний угол)
|
||||
self.ax_drone_view = self.fig.add_subplot(gs[0, 0])
|
||||
self.ax_drone_view.set_title('Вид БПЛА')
|
||||
self.ax_drone_view.axis('off')
|
||||
|
||||
# Глобальная карта (левый нижний угол)
|
||||
self.ax_global_map = self.fig.add_subplot(gs[1, 0])
|
||||
self.ax_global_map.set_title('Global Map - Траектория полета беспилотника')
|
||||
self.ax_global_map.set_xlabel('X координата')
|
||||
self.ax_global_map.set_ylabel('Y координата')
|
||||
@@ -66,8 +75,8 @@ class VisualizationManager:
|
||||
self.ax_global_map.axhline(y=0, color='k', linestyle='-', alpha=0.3)
|
||||
self.ax_global_map.axvline(x=0, color='k', linestyle='-', alpha=0.3)
|
||||
|
||||
# Детекция ключевых точек (правый нижний угол)
|
||||
self.ax_detection = self.fig.add_subplot(gs[1, 0])
|
||||
# Детекция ключевых точек (правый верхний угол)
|
||||
self.ax_detection = self.fig.add_subplot(gs[0, 1])
|
||||
self.ax_detection.set_title('Keypoint Detection')
|
||||
self.ax_detection.axis('off')
|
||||
|
||||
@@ -100,7 +109,7 @@ class VisualizationManager:
|
||||
if len(self.trajectory_x) > 1:
|
||||
# Разделяем траекторию по режимам
|
||||
operator_indices = [i for i, m in enumerate(self.trajectory_modes) if m == SimMode.OPERATOR]
|
||||
autonome_indices = [i for i, m in enumerate(self.trajectory_modes) if m == SimMode.AUTONOME]
|
||||
autonome_indices = operator_indices[-1:] + [i for i, m in enumerate(self.trajectory_modes) if m == SimMode.AUTONOME]
|
||||
|
||||
# Рисуем траекторию оператора (синий цвет)
|
||||
if len(operator_indices) > 1:
|
||||
@@ -139,6 +148,24 @@ class VisualizationManager:
|
||||
self.ax_global_map.set_xlim(x_min - margin, x_max + margin)
|
||||
self.ax_global_map.set_ylim(y_min - margin, y_max + margin)
|
||||
|
||||
def update_drone_view(self, image: np.ndarray):
|
||||
"""Обновляет вид БПЛА"""
|
||||
self.drone_view_image = image.copy()
|
||||
|
||||
self.ax_drone_view.clear()
|
||||
self.ax_drone_view.set_title('Вид БПЛА')
|
||||
|
||||
if image is not None:
|
||||
# Конвертируем BGR в RGB для matplotlib
|
||||
if len(image.shape) == 3 and image.shape[2] == 3:
|
||||
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
|
||||
else:
|
||||
image_rgb = image
|
||||
|
||||
self.ax_drone_view.imshow(image_rgb)
|
||||
|
||||
self.ax_drone_view.axis('off')
|
||||
|
||||
def update_detection(self, image: np.ndarray, keypoints):
|
||||
"""Обновляет визуализацию детекции ключевых точек"""
|
||||
self.current_frame = image.copy()
|
||||
|
||||
Reference in New Issue
Block a user