Skip to content

Instantly share code, notes, and snippets.

@irudnyts
Last active January 30, 2024 20:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irudnyts/56871144303da8ce31e3bf5250555da2 to your computer and use it in GitHub Desktop.
Save irudnyts/56871144303da8ce31e3bf5250555da2 to your computer and use it in GitHub Desktop.
from djitellopy import Tello
import pygame
import cv2
import numpy as np
pygame.init()
screen = pygame.display.set_mode((320, 240))
drone = Tello()
drone.connect()
drone.set_video_direction(Tello.CAMERA_DOWNWARD) # рядок, який змінює камеру
drone.streamon()
frame_read = drone.get_frame_read()
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
drone.streamoff()
running = False
frame = frame_read.frame
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame = np.rot90(frame)
frame = np.flipud(frame)
frame = pygame.surfarray.make_surface(frame)
screen.blit(frame, (0, 0))
pygame.display.flip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment