Paparazzi UAS
v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
|
Estimate velocity from optic flow. More...
#include "std.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "opticflow_calculator.h"
#include "lib/vision/image.h"
#include "lib/vision/lucas_kanade.h"
#include "lib/vision/fast_rosten.h"
#include "size_divergence.h"
#include "linear_flow_fit.h"
Go to the source code of this file.
Macros | |
#define | SIZE_DIV 1 |
#define | LINEAR_FIT 1 |
#define | OPTICFLOW_FOV_W 0.89360857702 |
#define | OPTICFLOW_FOV_H 0.67020643276 |
#define | OPTICFLOW_FX 343.1211 |
#define | OPTICFLOW_FY 348.5053 |
#define | OPTICFLOW_MAX_TRACK_CORNERS 25 |
#define | OPTICFLOW_WINDOW_SIZE 10 |
#define | OPTICFLOW_SUBPIXEL_FACTOR 10 |
#define | OPTICFLOW_MAX_ITERATIONS 10 |
#define | OPTICFLOW_THRESHOLD_VEC 2 |
#define | OPTICFLOW_FAST9_ADAPTIVE TRUE |
#define | OPTICFLOW_FAST9_THRESHOLD 20 |
#define | OPTICFLOW_FAST9_MIN_DISTANCE 10 |
Functions | |
static uint32_t | timeval_diff (struct timeval *starttime, struct timeval *finishtime) |
Calculate the difference from start till finish. More... | |
static int | cmp_flow (const void *a, const void *b) |
Compare two flow vectors based on flow distance Used for sorting. More... | |
void | opticflow_calc_init (struct opticflow_t *opticflow, uint16_t w, uint16_t h) |
Initialize the opticflow calculator. More... | |
void | opticflow_calc_frame (struct opticflow_t *opticflow, struct opticflow_state_t *state, struct image_t *img, struct opticflow_result_t *result) |
Run the optical flow on a new image frame. More... | |
Estimate velocity from optic flow.
Using images from a vertical camera and IMU sensor data.
Definition in file opticflow_calculator.c.
#define LINEAR_FIT 1 |
Definition at line 51 of file opticflow_calculator.c.
Referenced by opticflow_calc_frame().
#define OPTICFLOW_FAST9_ADAPTIVE TRUE |
Definition at line 101 of file opticflow_calculator.c.
Referenced by opticflow_calc_init().
#define OPTICFLOW_FAST9_MIN_DISTANCE 10 |
Definition at line 111 of file opticflow_calculator.c.
Referenced by opticflow_calc_init().
#define OPTICFLOW_FAST9_THRESHOLD 20 |
Definition at line 106 of file opticflow_calculator.c.
Referenced by opticflow_calc_init().
#define OPTICFLOW_FOV_H 0.67020643276 |
Definition at line 60 of file opticflow_calculator.c.
Referenced by opticflow_calc_frame().
#define OPTICFLOW_FOV_W 0.89360857702 |
Definition at line 55 of file opticflow_calculator.c.
Referenced by opticflow_calc_frame().
#define OPTICFLOW_FX 343.1211 |
Definition at line 65 of file opticflow_calculator.c.
Referenced by opticflow_calc_frame().
#define OPTICFLOW_FY 348.5053 |
Definition at line 70 of file opticflow_calculator.c.
Referenced by opticflow_calc_frame().
#define OPTICFLOW_MAX_ITERATIONS 10 |
Definition at line 91 of file opticflow_calculator.c.
Referenced by opticflow_calc_init().
#define OPTICFLOW_MAX_TRACK_CORNERS 25 |
Definition at line 76 of file opticflow_calculator.c.
Referenced by opticflow_calc_init().
#define OPTICFLOW_SUBPIXEL_FACTOR 10 |
Definition at line 86 of file opticflow_calculator.c.
Referenced by opticflow_calc_init().
#define OPTICFLOW_THRESHOLD_VEC 2 |
Definition at line 96 of file opticflow_calculator.c.
Referenced by opticflow_calc_init().
#define OPTICFLOW_WINDOW_SIZE 10 |
Definition at line 81 of file opticflow_calculator.c.
Referenced by opticflow_calc_init().
#define SIZE_DIV 1 |
Definition at line 48 of file opticflow_calculator.c.
Referenced by opticflow_calc_frame().
|
static |
Compare two flow vectors based on flow distance Used for sorting.
[in] | *a | The first flow vector (should be vect flow_t) |
[in] | *b | The second flow vector (should be vect flow_t) |
Definition at line 331 of file opticflow_calculator.c.
References flow_t::flow_x, and flow_t::flow_y.
Referenced by opticflow_calc_frame().
void opticflow_calc_frame | ( | struct opticflow_t * | opticflow, |
struct opticflow_state_t * | state, | ||
struct image_t * | img, | ||
struct opticflow_result_t * | result | ||
) |
Run the optical flow on a new image frame.
[in] | *opticflow | The opticalflow structure that keeps track of previous images |
[in] | *state | The state of the drone |
[in] | *img | The image frame to calculate the optical flow from |
[out] | *result | The optical flow result |
Definition at line 155 of file opticflow_calculator.c.
References opticflow_state_t::agl, analyze_linear_flow_field(), cmp_flow(), opticflow_result_t::corner_cnt, opticflow_result_t::div_size, opticflow_result_t::divergence, linear_flow_fit_info::divergence, opticflow_t::fast9_adaptive, fast9_detect(), opticflow_t::fast9_min_distance, opticflow_t::fast9_threshold, opticflow_result_t::flow_der_x, opticflow_result_t::flow_der_y, opticflow_result_t::flow_x, flow_t::flow_x, opticflow_result_t::flow_y, flow_t::flow_y, opticflow_result_t::fps, get_size_divergence(), opticflow_t::got_first_img, image_t::h, image_copy(), image_show_flow(), image_show_points(), image_switch(), image_to_grayscale(), opticflow_t::img_gray, LINEAR_FIT, opticflow_t::max_iterations, opticflow_t::max_track_corners, opticflow_result_t::noise_measurement, OPTICFLOW_FOV_H, OPTICFLOW_FOV_W, OPTICFLOW_FX, OPTICFLOW_FY, opticFlowLK(), opticflow_state_t::phi, opticflow_t::prev_img_gray, opticflow_t::prev_phi, opticflow_t::prev_theta, opticflow_t::prev_timestamp, SIZE_DIV, opticflow_t::subpixel_factor, linear_flow_fit_info::surface_roughness, opticflow_result_t::surface_roughness, opticflow_state_t::theta, opticflow_t::threshold_vec, timeval_diff(), opticflow_result_t::tracked_cnt, TRUE, image_t::ts, opticflow_result_t::vel_x, opticflow_result_t::vel_y, image_t::w, and opticflow_t::window_size.
Referenced by opticflow_module_calc().
void opticflow_calc_init | ( | struct opticflow_t * | opticflow, |
uint16_t | w, | ||
uint16_t | h | ||
) |
Initialize the opticflow calculator.
[out] | *opticflow | The new optical flow calculator |
[in] | *w | The image width |
[in] | *h | The image height |
Definition at line 125 of file opticflow_calculator.c.
References FALSE, image_create(), IMAGE_GRAYSCALE, OPTICFLOW_FAST9_ADAPTIVE, OPTICFLOW_FAST9_MIN_DISTANCE, OPTICFLOW_FAST9_THRESHOLD, OPTICFLOW_MAX_ITERATIONS, OPTICFLOW_MAX_TRACK_CORNERS, OPTICFLOW_SUBPIXEL_FACTOR, OPTICFLOW_THRESHOLD_VEC, and OPTICFLOW_WINDOW_SIZE.
Referenced by opticflow_module_init().
|
static |
Calculate the difference from start till finish.
[in] | *starttime | The start time to calculate the difference from |
[in] | *finishtime | The finish time to calculate the difference from |
Definition at line 316 of file opticflow_calculator.c.
Referenced by opticflow_calc_frame().