Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
opticflow_calculator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Hann Woei Ho
3  * 2015 Freek van Tienen <freek.v.tienen@gmail.com>
4  * 2016 Kimberly McGuire <k.n.mcguire@tudelft.nl
5  *
6  * This file is part of Paparazzi.
7  *
8  * Paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * Paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Paparazzi; see the file COPYING. If not, see
20  * <http://www.gnu.org/licenses/>.
21  */
22 
32 #ifndef OPTICFLOW_CALCULATOR_H
33 #define OPTICFLOW_CALCULATOR_H
34 
35 #include "std.h"
36 #include "inter_thread_data.h"
37 #include "lib/vision/image.h"
38 #include "lib/v4l/v4l2.h"
39 
40 struct opticflow_t {
43  struct image_t img_gray;
45 
50  bool derotation;
52 
55 
56  bool track_back;
57  bool show_flow;
58 
64 
70 
76 
81 
82  const struct video_config_t *camera;
84 };
85 
86 #define FAST9_MAX_CORNERS 512
87 
88 extern void opticflow_calc_init(struct opticflow_t opticflow[]);
89 extern bool opticflow_calc_frame(struct opticflow_t *opticflow, struct image_t *img,
90  struct opticflow_result_t *result);
91 
92 extern bool calc_fast9_lukas_kanade(struct opticflow_t *opticflow, struct image_t *img,
93  struct opticflow_result_t *result);
94 extern bool calc_edgeflow_tot(struct opticflow_t *opticflow, struct image_t *img,
95  struct opticflow_result_t *result);
96 
97 extern void kalman_filter_opticflow_velocity(float *velocity_x, float *velocity_y, float *acceleration_measurement, float fps,
98  float *measurement_noise, float process_noise, bool reinitialize_kalman);
99 
100 #endif /* OPTICFLOW_CALCULATOR_H */
101 
102 
opticflow_calc_frame
bool opticflow_calc_frame(struct opticflow_t *opticflow, struct image_t *img, struct opticflow_result_t *result)
Run the optical flow on a new image frame.
Definition: opticflow_calculator.c:1169
uint16_t
unsigned short uint16_t
Definition: types.h:16
opticflow_t::feature_management
bool feature_management
Decides whether to keep track corners in memory for the next frame instead of re-detecting every time...
Definition: opticflow_calculator.h:73
opticflow_t::fast9_ret_corners
struct point_t * fast9_ret_corners
Corners.
Definition: opticflow_calculator.h:72
opticflow_t::max_iterations
uint8_t max_iterations
The maximum amount of iterations the Lucas Kanade algorithm should do.
Definition: opticflow_calculator.h:61
inter_thread_data.h
Inter-thread data structures.
opticflow_t::fast9_num_regions
uint8_t fast9_num_regions
The number of regions of interest the image is split into.
Definition: opticflow_calculator.h:75
opticflow_t::derotation_correction_factor_y
float derotation_correction_factor_y
Correction factor for derotation in Y axis, determined from a fit from the gyros and flow rotation....
Definition: opticflow_calculator.h:54
opticflow_t::fast9_rsize
uint16_t fast9_rsize
Amount of corners allocated.
Definition: opticflow_calculator.h:71
opticflow_t
Definition: opticflow_calculator.h:40
opticflow_t::fast9_min_distance
uint16_t fast9_min_distance
Minimum distance in pixels between corners.
Definition: opticflow_calculator.h:68
opticflow_t::img_gray
struct image_t img_gray
Current gray image frame.
Definition: opticflow_calculator.h:43
opticflow_t::max_track_corners
uint16_t max_track_corners
Maximum amount of corners Lucas Kanade should track.
Definition: opticflow_calculator.h:65
opticflow_t::window_size
uint16_t window_size
Window size for the blockmatching algorithm (general value for all methods)
Definition: opticflow_calculator.h:48
opticflow_t::derotation
bool derotation
Derotation switched on or off (depended on the quality of the gyroscope measurement)
Definition: opticflow_calculator.h:50
opticflow_t::prev_img_gray
struct image_t prev_img_gray
Previous gray image frame.
Definition: opticflow_calculator.h:44
opticflow_t::fast9_padding
uint16_t fast9_padding
Padding used in FAST9 detector.
Definition: opticflow_calculator.h:69
opticflow_t::actfast_short_step
float actfast_short_step
Step size to take when there is an edge to be followed.
Definition: opticflow_calculator.h:78
opticflow_t::derotation_correction_factor_x
float derotation_correction_factor_x
Correction factor for derotation in x axis, determined from a fit from the gyros and flow rotation....
Definition: opticflow_calculator.h:53
opticflow_t::corner_method
uint8_t corner_method
Method to use for determining where the corners are.
Definition: opticflow_calculator.h:47
std.h
opticflow_t::fast9_region_detect
bool fast9_region_detect
Decides whether to detect fast9 corners in specific regions of interest or the whole image (only for ...
Definition: opticflow_calculator.h:74
opticflow_t::actfast_gradient_method
int actfast_gradient_method
Whether to use a simple or Sobel filter.
Definition: opticflow_calculator.h:80
opticflow_t::pyramid_level
uint8_t pyramid_level
Number of pyramid levels used in Lucas Kanade algorithm (0 == no pyramids used)
Definition: opticflow_calculator.h:63
opticflow_t::id
uint8_t id
Definition: opticflow_calculator.h:83
opticflow_t::subpixel_factor
uint16_t subpixel_factor
The amount of subpixels per pixel.
Definition: opticflow_calculator.h:59
kalman_filter_opticflow_velocity
void kalman_filter_opticflow_velocity(float *velocity_x, float *velocity_y, float *acceleration_measurement, float fps, float *measurement_noise, float process_noise, bool reinitialize_kalman)
opticflow_t::got_first_img
bool got_first_img
If we got a image to work with.
Definition: opticflow_calculator.h:41
uint8_t
unsigned char uint8_t
Definition: types.h:14
v4l2.h
opticflow_t::median_filter
bool median_filter
Decides to use a median filter on the velocity.
Definition: opticflow_calculator.h:51
opticflow_t::fast9_adaptive
bool fast9_adaptive
Whether the FAST9 threshold should be adaptive.
Definition: opticflow_calculator.h:66
opticflow_calc_init
void opticflow_calc_init(struct opticflow_t opticflow[])
Initialize the opticflow calculator.
Definition: opticflow_calculator.c:396
opticflow_t::fast9_threshold
uint8_t fast9_threshold
FAST9 corner detection threshold.
Definition: opticflow_calculator.h:67
image.h
opticflow_t::actfast_long_step
float actfast_long_step
Step size to take when there is no texture.
Definition: opticflow_calculator.h:77
video_config_t::fps
int fps
Target FPS.
Definition: video_device.h:67
opticflow_t::track_back
bool track_back
Whether to track flow vectors back to the previous image, in order to check if the back-tracked flow ...
Definition: opticflow_calculator.h:56
calc_fast9_lukas_kanade
bool calc_fast9_lukas_kanade(struct opticflow_t *opticflow, struct image_t *img, struct opticflow_result_t *result)
Run the optical flow with fast9 and lukaskanade on a new image frame.
Definition: opticflow_calculator.c:492
opticflow_t::just_switched_method
bool just_switched_method
Boolean to check if methods has been switched (for reinitialization)
Definition: opticflow_calculator.h:42
opticflow_t::actfast_min_gradient
int actfast_min_gradient
Threshold that decides when there is sufficient texture for edge following.
Definition: opticflow_calculator.h:79
opticflow_t::resolution_factor
uint16_t resolution_factor
The resolution in EdgeFlow to determine the Divergence.
Definition: opticflow_calculator.h:60
calc_edgeflow_tot
bool calc_edgeflow_tot(struct opticflow_t *opticflow, struct image_t *img, struct opticflow_result_t *result)
Run the optical flow with EDGEFLOW on a new image frame.
Definition: opticflow_calculator.c:1006
opticflow
struct opticflow_t opticflow[ACTIVE_CAMERAS]
Opticflow calculations.
Definition: opticflow_module.c:65
opticflow_t::method
uint8_t method
Method to use to calculate the optical flow.
Definition: opticflow_calculator.h:46
opticflow_t::threshold_vec
uint8_t threshold_vec
The threshold in x, y subpixels which the algorithm should stop.
Definition: opticflow_calculator.h:62
opticflow_t::show_flow
bool show_flow
Whether to draw the flow vectors on the image. Watch out! This changes the image as will be received ...
Definition: opticflow_calculator.h:57
opticflow_t::camera
const struct video_config_t * camera
Definition: opticflow_calculator.h:82
point_t
Definition: image.h:58
opticflow_t::search_distance
uint16_t search_distance
Search distance for blockmatching alg.
Definition: opticflow_calculator.h:49
image_t
Definition: image.h:44
opticflow_result_t
Definition: inter_thread_data.h:37
video_config_t
V4L2 device settings.
Definition: video_device.h:55