Paparazzi UAS  v5.15_devel-113-g1b57ff1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
linear_flow_fit.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 de Croon, Hann Woei Ho
3  *
4  * This file is part of Paparazzi.
5  *
6  * Paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * Paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
22 /*
23  * @file paparazzi/sw/airborne/modules/computer_vision/opticflow/linear_flow_fit.h
24  * @brief Takes a set of optical flow vectors and extracts information such as relative velocities and surface roughness.
25  *
26  * A horizontal and vertical linear fit is made with the optical flow vectors, and from the fit parameters information is extracted such as relative velocities (useful for time-to-contact determination), slope angle, and surface roughness.
27  *
28  * Code based on the article:
29  * "Optic-flow based slope estimation for autonomous landing",
30  * de Croon, G.C.H.E., and Ho, H.W., and De Wagter, C., and van Kampen, E., and Remes B., and Chu, Q.P.,
31  * in the International Journal of Micro Air Vehicles, Volume 5, Number 4, pages 287 – 297, (2013)
32  */
33 
34 #include "lib/vision/image.h"
35 
36 #ifndef LINEAR_FLOW_FIT
37 #define LINEAR_FLOW_FIT
38 
39 // structure that contains all outputs of a linear flow fied fit:
41  float slope_x;
42  float slope_y;
50  float divergence;
51  float fit_error;
54 };
55 
56 // This is the function called externally, passing the vector of optical flow vectors and information on the number of vectors and image size:
57 bool analyze_linear_flow_field(struct flow_t *vectors, int count, float error_threshold, int n_iterations, int n_samples, int im_width, int im_height, struct linear_flow_fit_info *info);
58 
59 // Fits the linear flow field with RANSAC:
60 void fit_linear_flow_field(struct flow_t *vectors, int count, float error_threshold, int n_iterations, int n_samples, float *parameters_u, float *parameters_v, float *fit_error, float *min_error_u, float *min_error_v, int *n_inliers_u, int *n_inliers_v);
61 
62 // Extracts relevant information from the fit parameters:
63 void extract_information_from_parameters(float *parameters_u, float *parameters_v, int im_width, int im_height, struct linear_flow_fit_info *info);
64 
65 
66 #endif
float relative_velocity_y
Relative velocity in y-direction, i.e., vy / z, where z is the depth in direction of the camera's pri...
float fit_error
Error of the fit (same as surface roughness)
int n_inliers_u
Number of inliers in the horizontal flow fit.
void fit_linear_flow_field(struct flow_t *vectors, int count, float error_threshold, int n_iterations, int n_samples, float *parameters_u, float *parameters_v, float *fit_error, float *min_error_u, float *min_error_v, int *n_inliers_u, int *n_inliers_v)
Analyze a linear flow field, retrieving information such as divergence, surface roughness, focus of expansion, etc.
Definition: image.h:66
float relative_velocity_z
Relative velocity in z-direction, i.e., vz / z, where z is the depth in direction of the camera's pri...
float time_to_contact
Basically, 1 / relative_velocity_z.
int n_samples
Definition: detect_gate.c:85
Image helper functions like resizing, color filter, converters...
float focus_of_expansion_x
Image x-coordinate of the focus of expansion (contraction)
float focus_of_expansion_y
Image y-coordinate of the focus of expansion (contraction)
float slope_y
Slope of the surface in y-direction - given sufficient lateral motion.
float relative_velocity_x
Relative velocity in x-direction, i.e., vx / z, where z is the depth in direction of the camera's pri...
float slope_x
Slope of the surface in x-direction - given sufficient lateral motion.
int n_inliers_v
Number of inliers in the vertical flow fit.
float divergence
Basically, relative_velocity_z. Actual divergence of a 2D flow field is 2 * relative_velocity_z.
void extract_information_from_parameters(float *parameters_u, float *parameters_v, int im_width, int im_height, struct linear_flow_fit_info *info)
Extract information from the parameters that were fit to the optical flow field.
float surface_roughness
The error of the linear fit is a measure of surface roughness.
bool analyze_linear_flow_field(struct flow_t *vectors, int count, float error_threshold, int n_iterations, int n_samples, int im_width, int im_height, struct linear_flow_fit_info *info)
Analyze a linear flow field, retrieving information such as divergence, surface roughness, focus of expansion, etc.