Last active
January 30, 2024 20:31
-
-
Save irudnyts/56871144303da8ce31e3bf5250555da2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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