This is not a fork of somebody else's code. I, @BobMcDear, am the original creator of this project but due to problems with Git was forced to delete and restore it. In other words, maciektbt4/Tello-Face-Tracker is a fork of this repository and not vice versa.
This is an implementation of a face tracker for the Ryze Tello drone.
To run the face tracker, you must first download the Caffe model for face detection and its associated text description.
Next, main.py
needs to be run, and the paths to the model and architecture description are to be provided. Assuming your device's Wi-Fi is linked to that
of the Tello, this would connect to the drone, take off, and track the main face within the camera's field of view so it is in front of the drone. The drone's video stream is displayed
and identified faces are shown with bounding boxes.
Example:
python main.py --model_file res10_300x300_ssd_iter_140000.caffemodel --proto_file deploy.prototxt.txt
The implemented modules may also be used out-of-the-box. They include,
face_detection.py
:get_caffe_net
: Reads a Caffe network with OpenCV- Args:
proto_file (str)
: Path to the .prototxt file that contains the model's textual description. Default isdeploy.prototxt.txt
model_file (str)
: Path to the model's parameters. Default isres10_300x300_ssd_iter_140000.caffemodel
- Returns (
dnn_Net
): The Caffe network
- Args:
get_faces
: Identifies faces in an image- Args:
net (dnn_Net)
:dnn_Net
for face identification (e.g., the one linked above)image (array)
: Image, represented as a NumPy array
- Returns (
List[Tuple[int, int, int, int, float]]
): List of detected faces, where each element is a Tuple in the form of [top-left X-coordinate, top-left Y-coordinate, bottom-right X-coordinate, bottom-right Y-coordinate, confidence] associated with a face. Only faces with scores of over 0.75 are included.
- Args:
get_most_confident_face
: Identifies the face in an image with the highest confidence- Args:
net (dnn_Net)
:dnn_Net
for face identification (e.g., the one linked above)image (array)
: Image, represented as a NumPy array
- Returns (
Tuple[int, int, int, int]
): Tuple in the form of [top-left X-coordinate, top-left Y-coordinate, bottom-right X-coordinate, bottom-right Y-coordinate] for the face with the highest confidence
- Args:
face_tracking.py
:Controls
: A control system for tracking objects with the Tello. All methods are@staticmethod
.get_forward_backward_velocity
: Gets the best forward/backward velocity for tracking an object- Args:
x1 (int)
: X-coordinate of the top-left corner of the objecty1 (int)
: Y-coordinate of the top-left corner of the objectx2 (int)
: X-coordinate of the bottom-right corner of the objecty2 (int)
: Y-coordinate of the bottom-right corner of the object
- Returns (
int
): Forward/backward velocity for tracking the specified object
- Args:
get_up_down_velocity
: Gets the best up/down velocity for tracking an object- Args:
y1 (int)
: Y-coordinate of the top-left corner of the objecty2 (int)
: Y-coordinate of the bottom-right corner of the object
- Returns (
int
): Up/down velocity for tracking the specified object
- Args:
get_yaw_velocity
: Gets the best yaw velocity for tracking an object- Args:
x1 (int)
: X-coordinate of the top-left corner of the objectx2 (int)
: X-coordinate of the bottom-right corner of the object
- Returns (
int
): Yaw velocity for tracking the specified object
- Args:
get_rc_controls
: Gets the best forward/backward, up/down, and yaw velocities for tracking an object- Args:
x1 (int)
: X-coordinate of the top-left corner of the objecty1 (int)
: Y-coordinate of the top-left corner of the objectx2 (int)
: X-coordinate of the bottom-right corner of the objecty2 (int)
: Y-coordinate of the bottom-right corner of the object
- Returns (
Tuple[int, int, int, int]
): The first element is always zero, and after that, it's forward/backward, up/down, and yaw velocities for tracking the specified object
- Args:
FaceTracker
: Communicates with the Tello and tracks faces__init__
: Connects to the drone and sets up the face detector- Args:
proto_file (str)
: Path to the .prototxt file that contains the model's textual description. Default isdeploy.prototxt.txt
model_file (str)
: Path to the model's parameters. Default isres10_300x300_ssd_iter_140000.caffemodel
- Args:
get_frame
: Gets the camera's current frame, resized to 300 X 300- Returns (
array
): The current frame as a NumPyarray
, resized to 300 X 300
- Returns (
track_face
: Tracks faces in the current video frame