feat: motion graphic on gomography matrix

This commit is contained in:
2025-10-04 23:08:26 +03:00
parent dc8c869bcf
commit e5715e17da
4 changed files with 135 additions and 91 deletions

View File

@@ -272,11 +272,6 @@ class AutoPilot(Pilot):
height, width = self.prev_image.shape[:2]
self.image_center = (width // 2, height // 2)
# Обновляем визуализацию детекции
if self.vis_manager is not None:
kp, _ = self.orb_detector.detectAndCompute(self.prev_image, None)
self.vis_manager.update_detection(self.prev_image, kp)
return PilotCommand()
# Конвертируем текущее изображение
@@ -314,8 +309,6 @@ class AutoPilot(Pilot):
# Обновляем визуализацию
if self.vis_manager:
# Обновляем детекцию ключевых точек
self.vis_manager.update_detection(current_image, kp2)
# Обновляем сопоставление точек
self.vis_manager.update_matches(
@@ -323,6 +316,16 @@ class AutoPilot(Pilot):
current_image,
kp1, kp2, matches,
transformation_info)
self.vis_manager.update_motion_vectors(
current_image,
kp1, kp2, matches)
mask = transformation_info['mask']
self.vis_manager.update_motion_gomography(
current_image,
kp1, kp2,
np.array(matches)[mask.ravel().astype(bool)])
# Пытаемся найти ориентир на картинке:
landmark_image = cv2.imread(Path('chunks') / f'chunk_{self.target_idx}.png', cv2.IMREAD_COLOR_RGB)
@@ -389,45 +392,3 @@ class AutoPilot(Pilot):
self.y = y
self.angle = angle
self.frame_count = 0
class RandomPilot(Pilot):
counter: int
def __init__(self, velocity: float = 1):
self.counter = 0
def act(self) -> tuple[float, float] | None:
self.counter += 1
if self.counter > 300:
return None
return 1 / (self.counter + 20), 10.0
# def _test():
# randomPilot = RandomPilot()
# point = [0, 0]
# iter_count = 100
# points = [point.copy()]
# for i in range(iter_count):
# dx, dy = randomPilot.step()
# prev_point = point.copy()
# point[0] += dx
# point[1] += dy
# points.append(point.copy())
# coords = list(zip(*points))
# padding = 5
# plt.axis([
# min(coords[0]) - padding, max(coords[0]) + padding,
# min(coords[1]) - padding, max(coords[1]) + padding])
# for i in range(iter_count):
# plt.plot(coords[0][i:i+2], coords[1][i:i+2], color='#5e5')
# plt.pause(0.05)
# sleep(1)
# if __name__ == '__main__':
# _test()