Skip to content

Instantly share code, notes, and snippets.

@f41ardu
Last active October 16, 2023 12:20
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save f41ardu/b75da46dae383e5c835295600deef604 to your computer and use it in GitHub Desktop.
Save f41ardu/b75da46dae383e5c835295600deef604 to your computer and use it in GitHub Desktop.
Raspberry, python3.7, opencv and Tello.
#
# --- (c) 01/2020 f41ardu
#
# Tello cam using opencv proof of concept
# issue: huge delay -> Tipp scale down video size for improved performance on Raspberry PI 3+
# May also work with older versions of opencv supporting incomming udp streams.
#
#import numpy as np
# import opencv 4.2.0
import cv2
import time
telloVideo = cv2.VideoCapture("udp://@0.0.0.0:11111")
#telloVideo.set(cv2.CAP_PROP_FPS, 3)
# 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('q'):
break
# When everything done, release the capture
telloVideo.release()
cv2.destroyAllWindows()
@f41ardu
Copy link
Author

f41ardu commented Jan 22, 2020

Improved version!

@frank804
Copy link

frank804 commented Jul 6, 2020

when I use this , should i change ip and port?

@f41ardu
Copy link
Author

f41ardu commented Aug 3, 2020

Feel free to use the local IP address and port. 0.0.0.0 is seamless, use the locak adress of your system.

@YixiaoOneSmile
Copy link

Thank you! Referring to your code, I modified the official example to the version of Python 3

@juanmill4
Copy link

how can i remove the latency i have 1 seconds of latency

@Leofeng10
Copy link

Thank you so much! I managed to transfer the Tello project to Python 3 using your script!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment