Hello Tello Pilot!
Join our DJI Tello community & remove this banner.
Sign up

Taking Pictures with Tello Drone using Python 3

SunshineBunny

New member
Joined
Feb 10, 2020
Messages
2
Reaction score
0
Hi! I'm a middle grade student and I'm currently working on a project that involves making a program in Python 3 that lets the user control a Tello drone with arrow keys and letters on a computer. When the "s" key is clicked, the drone will take a picture. So far, I was able to get a live video feed from the drone with the easytello library, but I still need help finding a way for the drone to take a picture and save it to a certain directory in my computer. Thank you and I would really appreciate the help!
 

f41ardu

Well-known member
Joined
Jan 3, 2019
Messages
56
Reaction score
20
Location
Back in Stuttgart ;->
Pretty Easy:

Run this as seperate python script. One to controll tello and this one to take pictures. send streamon to tello and you see the video. Move the mouse pointer into the video window and press 's' to take a picure. The rest is up to you.

Python:
#
# --- (c) 02/2020 f41ardu
#
# Tello cam using opencv proof of concept
#
#

# import opencv 4.2.0
import cv2

telloVideo = cv2.VideoCapture("udp://@0.0.0.0:11111")


# wait for frame
ret = False
# scale down
scale = 3

while(True):
    # Capture frame-by-framestreamon
    ret, frame = telloVideo.read()
    if(ret):
    # Our operations on the frame come here
        height , width , layers =  frame.shape
        new_h=int(height/scale)
        new_w=int(width/scale)
        resize = cv2.resize(frame, (new_w, new_h)) # <- resize for improved performance
        # Display the resulting frame
        cv2.imshow('Tello',resize)
        
    if cv2.waitKey(1) & 0xFF == ord('s'):
        cv2.imwrite("test.jpg",resize) # writes image test.bmp to disk
        print("Take Picture")
    
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
telloVideo.release()
cv2.destroyAllWindows()
 
  • Like
Reactions: SunshineBunny

SunshineBunny

New member
Joined
Feb 10, 2020
Messages
2
Reaction score
0
Pretty Easy:

Run this as seperate python script. One to controll tello and this one to take pictures. send streamon to tello and you see the video. Move the mouse pointer into the video window and press 's' to take a picure. The rest is up to you.

Python:
#
# --- (c) 02/2020 f41ardu
#
# Tello cam using opencv proof of concept
#
#

# import opencv 4.2.0
import cv2

telloVideo = cv2.VideoCapture("udp://@0.0.0.0:11111")


# wait for frame
ret = False
# scale down
scale = 3

while(True):
    # Capture frame-by-framestreamon
    ret, frame = telloVideo.read()
    if(ret):
    # Our operations on the frame come here
        height , width , layers =  frame.shape
        new_h=int(height/scale)
        new_w=int(width/scale)
        resize = cv2.resize(frame, (new_w, new_h)) # <- resize for improved performance
        # Display the resulting frame
        cv2.imshow('Tello',resize)
       
    if cv2.waitKey(1) & 0xFF == ord('s'):
        cv2.imwrite("test.jpg",resize) # writes image test.bmp to disk
        print("Take Picture")
   
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# When everything done, release the capture
telloVideo.release()
cv2.destroyAllWindows()
It works! Thank you so much for the help! :)
 

New Threads

Members online

Forum statistics

Threads
4,072
Messages
30,957
Members
10,407
Latest member
Perun