Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
rust_drone_follow
This is a Rust library that aims to be able to control a drone, in order to have it follow a hat, that it detects with it's downwards facing camera. (a compatible drone is for example: Parrot AR Drone 2.0)
This library contains some basic detectors and filters but is extendable by the traits they implement.
HatFollower
The heart of this library is the HatFollower struct that is generic with three types. It needs a Detector, a Controller, and a Filter.
It has a run
function that will start up the drone and start following the hat.
Example of instantiation, and usage:
!!! Beware, if you use a real controller and you don't pass a Receiver when instantiating this or/and you don't run it on a separate thread it will run indefinitely !!!
Settings
You can change settings by giving the HatFollower a different setting struct at the beginning. There are three pre-made settings, but you can always create your own.
new()
=> Returns settings with a default setting: (show video, no save, no draw)
debug()
=> Returns settings with full debug setting: (show video, save video, draw all)
silent()
=> Returns settings with silent setting: (no video, no save, no draw)
Detector
A detector is the part of the system that processes the video-frames, detects the hat on it (if it is there) and saves it's coordinates, transforming it to an descartes coordinate system, which has it's central point in the middle of the video frame. It also calculates the angle that the hat is facing. (in general it works with baseball caps)
NaiveDetector
This detector is included with the library. It requires a Hat struct which encodes three properties:
-
The color with lowest accepted values in Lab color space
-
The color with highest accepted values in Lab color space
-
The average size of the hat.
Example (looks for a dark blue baseball cap):
let hat = new;
If we have this struct we can simply instantiate our NaiveDetector:
let naive_detector = new;
We can detect the hat on a new image by calling it's detect_new_position
method.
This detector will always ignore previous positions, and will only use information from the new video-frame.
Controller
The controller is the part of the system that handles communication between the drone and the HatFollower. It also provides important information about certain properties of the drone, such as video resolution, and speed multiplier (meaning how fast should the drone move to travel a given distance calculated from the frame).
MockController
This library only provides a MockController, that returns a link to a video file which the HatFollower will read, and it ignores all commands given to it. It is useful to test the detection on prerecorded videos.
The video will be read by OpenCV, so any format supported by it will be supported by the MockController too.
To instantiate you have to give it a path string to the video file, and the resolution of the video.
let mock_controller = new;
Filter
The filter is the part of the system that is responsible for making sure, that no errors during detection mess up the tracking and following of the hat. It is also responsible for calculating the relative speed of the hat compared to the drone.
NoFilter
This library includes a filter that does no filtering, and only calculates the speed from the difference of the last point and the current point.
Example:
let no_filter = new;
KalmanFilter
This part is not yet implemented. Check back later.
Other useful utilities:
VideoExporter
Can be used to export frames to multiple video files.
Usage:
TextExporter
Can be used to save text to multiple files simultaneously.
Usage:
HatFileReader
Reads a file which is in the following format:
video_file_name
l1 a1 b1
l2 a2 b2
hat_size
Where l1, l2 are in range 0 - 100, a1, a2, b1, b2 are in range -127 - 127 and are integers, hat_size is a double, and video_file_name is a string containing the path to a video file.
You can use the results to feed in a MockController or a NaiveDetector
Any other rows after this will not be read.
Usage:
let = read_file;
Example file:
./kek.mp4
0 20 -127
80 127 -20
15200.0
PointConverter
Converts points from OpenCV to points in a descartes coordinate system which has O in the middle of the picture.
Instantiating:
let p_c = new;
After it you can use convert_from_image_coords
to convert from OpenCV Point to GeometricPoint (used in calculations),
and you can use convert_to_image_coords
to convert a GeometricPoint into OpenCV point.