Make a Tello drone follow you around — tracking your face or your hand with its camera, in real time.
PetDrone turns a DJI Tello into a camera that chases you. It reads the drone's live video feed on your computer, finds you in the frame, and steers the drone to keep you centred — turning, rising, and moving in or out so you stay in view as you move. Two versions are included: one that locks onto your face, and one that follows your open hand like a target it can't stop watching.
- Follow your face —
Follow.pyuses face detection to keep you centred and framed, closing in or backing off to hold a comfortable distance. - Follow your hand —
Rex.pyuses hand tracking; show it an open palm and it locks on and follows your hand around the room. - Smooth, real-time control — proportional controllers turn camera position into drone commands for yaw, height and forward/back, tuned to move smoothly instead of jerking.
- Safety limits — every control axis is capped to a maximum speed so the drone never lurches.
- Battery-aware startup — it checks the drone's battery on connect before doing anything.
- Live view — the camera feed is shown on screen with the tracking target drawn on, and a key press lands the drone at any time.
| Script | Tracker | Library |
|---|---|---|
Follow.py |
Face | OpenCV Haar cascade |
Rex.py |
Open hand | MediaPipe Hands |
Each frame, the tracker finds the target's position in the camera image. The horizontal offset becomes a turn command, the vertical offset a height command, and the target's size (how much of the frame it fills) a move-in/move-out command. A proportional gain converts each offset into a speed, clamped to a safe limit, and the result is streamed to the Tello over its Wi-Fi link.
-
Install the dependencies:
pip install djitellopy opencv-python mediapipe numpy -
Power on the Tello and connect your computer to the drone's Wi-Fi network.
-
Run one of the trackers:
python Follow.py # follow your face python Rex.py # follow your open hand
Give it room to fly and keep a hand near the keyboard to land it.
Python · djitellopy · OpenCV · MediaPipe · NumPy