Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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  float rotation_X;
55  float rotation_Y;
56  float rotation_Z;
57 };
58 
59 // This is the function called externally, passing the vector of optical flow vectors and information on the number of vectors and image size:
60 bool analyze_linear_flow_field(struct flow_t *vectors, int count, float error_threshold, int n_iterations,
61  int n_samples, int im_width, int im_height, struct linear_flow_fit_info *info);
62 
63 // Fits the linear flow field with RANSAC:
64 void fit_linear_flow_field(struct flow_t *vectors, int count, float error_threshold, int n_iterations, int n_samples,
65  float *parameters_u, float *parameters_v, float *fit_error, float *min_error_u, float *min_error_v, int *n_inliers_u,
66  int *n_inliers_v);
67 
68 // Extracts relevant information from the fit parameters:
69 void extract_information_from_parameters(float *parameters_u, float *parameters_v, int im_width, int im_height,
70  struct linear_flow_fit_info *info);
71 
72 // Analyze the optic flow field, also determining the rotations:
73 bool analyze_flow_field(struct flow_t *vectors, int count, float error_threshold, int n_iterations, int n_samples,
74  int im_width, int im_height, float focal_length, struct linear_flow_fit_info *info);
75 
76 
77 #endif
int n_samples
Definition: detect_gate.c:85
Image helper functions like resizing, color filter, converters...
Definition: image.h:78
float slope_x
Slope of the surface in x-direction - given sufficient lateral motion.
float divergence
Basically, relative_velocity_z. Actual divergence of a 2D flow field is 2 * relative_velocity_z.
int n_inliers_v
Number of inliers in the vertical flow fit.
float rotation_Z
Rotation around the Z axis.
float slope_y
Slope of the surface in y-direction - given sufficient lateral motion.
float focus_of_expansion_x
Image x-coordinate of the focus of expansion (contraction)
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,...
bool analyze_flow_field(struct flow_t *vectors, int count, float error_threshold, int n_iterations, int n_samples, int im_width, int im_height, float focal_length, struct linear_flow_fit_info *info)
Analyze a flow field, retrieving information on relative velocities and rotations,...
float time_to_contact
Basically, 1 / relative_velocity_z.
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...
int n_inliers_u
Number of inliers in the horizontal flow fit.
float rotation_X
Rotation around the X axis.
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 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,...
float focus_of_expansion_y
Image y-coordinate of the focus of expansion (contraction)
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)
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 rotation_Y
Rotation around the Y axis.