Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
|
Calculate velocity from optic flow. More...
#include "std.h"
#include "inter_thread_data.h"
#include "lib/vision/image.h"
#include "lib/v4l/v4l2.h"
Go to the source code of this file.
Data Structures | |
struct | opticflow_t |
Functions | |
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... | |
void | calc_fast9_lukas_kanade (struct opticflow_t *opticflow, struct opticflow_state_t *state, struct image_t *img, struct opticflow_result_t *result) |
Run the optical flow with fast9 and lukaskanade on a new image frame. More... | |
void | calc_edgeflow_tot (struct opticflow_t *opticflow, struct opticflow_state_t *state, struct image_t *img, struct opticflow_result_t *result) |
Run the optical flow with EDGEFLOW on a new image frame. More... | |
Calculate velocity from optic flow.
Using images from a vertical camera and IMU sensor data.
Definition in file opticflow_calculator.h.
struct opticflow_t |
Definition at line 40 of file opticflow_calculator.h.
Data Fields | ||
---|---|---|
bool | derotation | Derotation switched on or off (depended on the quality of the gyroscope measurement) |
bool | fast9_adaptive | Whether the FAST9 threshold should be adaptive. |
uint16_t | fast9_min_distance | Minimum distance in pixels between corners. |
uint16_t | fast9_padding | Padding used in FAST9 detector. |
struct point_t * | fast9_ret_corners | Corners. |
uint16_t | fast9_rsize | Amount of corners allocated. |
uint8_t | fast9_threshold | FAST9 corner detection threshold. |
bool | got_first_img | If we got a image to work with. |
struct image_t | img_gray | Current gray image frame. |
bool | just_switched_method | |
uint8_t | max_iterations | The maximum amount of iterations the Lucas Kanade algorithm should do. |
uint8_t | max_track_corners | Maximum amount of corners Lucas Kanade should track. |
bool | median_filter | Decides to use a median filter on the velocity. |
uint8_t | method | Method to use to calculate the optical flow. |
struct image_t | prev_img_gray | Previous gray image frame. |
struct FloatRates | prev_rates | Gyro Rates from the previous image frame. |
struct timeval | prev_timestamp | Timestamp of the previous frame, used for FPS calculation. |
uint8_t | pyramid_level | Number of pyramid levels used in Lucas Kanade algorithm (0 == no pyramids used) |
uint16_t | search_distance | Search distance for blockmatching alg. |
uint16_t | subpixel_factor | The amount of subpixels per pixel. |
uint8_t | threshold_vec | The threshold in x, y subpixels which the algorithm should stop. |
uint16_t | window_size | Window size for the blockmatching algorithm (general value for all methods) |
void calc_edgeflow_tot | ( | struct opticflow_t * | opticflow, |
struct opticflow_state_t * | state, | ||
struct image_t * | img, | ||
struct opticflow_result_t * | result | ||
) |
Run the optical flow with EDGEFLOW 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 404 of file opticflow_calculator.c.
References opticflow_state_t::agl, calc_previous_frame_nr(), calculate_edge_displacement(), calculate_edge_histogram(), opticflow_result_t::corner_cnt, opticflow_t::derotation, DISP_RANGE_MAX, opticflow_result_t::div_size, edge_flow_t::div_x, edge_flow_t::div_y, opticflow_result_t::divergence, draw_edgeflow_img(), FLOAT_RATES_ZERO, opticflow_result_t::flow_der_x, opticflow_result_t::flow_der_y, opticflow_result_t::flow_x, edge_flow_t::flow_x, opticflow_result_t::flow_y, edge_flow_t::flow_y, opticflow_result_t::fps, edge_hist_t::frame_time, getAmountPeaks(), image_t::h, opticflow_t::just_switched_method, line_fit(), MAX_HORIZON, MAX_WINDOW_SIZE, opticflow_t::median_filter, opticflow_result_t::noise_measurement, OPTICFLOW_FOV_H, OPTICFLOW_FOV_W, FloatRates::p, FloatRates::q, opticflow_state_t::rates, edge_hist_t::rates, RES, opticflow_t::search_distance, opticflow_t::subpixel_factor, opticflow_result_t::surface_roughness, timeval_diff(), opticflow_result_t::tracked_cnt, image_t::ts, update_median_filter(), opticflow_result_t::vel_x, opticflow_result_t::vel_y, vel_y_filt, image_t::w, opticflow_t::window_size, edge_hist_t::x, edgeflow_displacement_t::x, edge_hist_t::y, and edgeflow_displacement_t::y.
Referenced by opticflow_calc_frame().
void calc_fast9_lukas_kanade | ( | struct opticflow_t * | opticflow, |
struct opticflow_state_t * | state, | ||
struct image_t * | img, | ||
struct opticflow_result_t * | result | ||
) |
Run the optical flow with fast9 and lukaskanade 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 218 of file opticflow_calculator.c.
References opticflow_state_t::agl, analyze_linear_flow_field(), cmp_flow(), opticflow_result_t::corner_cnt, opticflow_t::derotation, opticflow_result_t::div_size, linear_flow_fit_info::divergence, opticflow_result_t::divergence, opticflow_t::fast9_adaptive, fast9_detect(), FAST9_HIGH_THRESHOLD, FAST9_LOW_THRESHOLD, opticflow_t::fast9_min_distance, opticflow_t::fast9_padding, opticflow_t::fast9_ret_corners, opticflow_t::fast9_rsize, 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, opticflow_t::just_switched_method, LINEAR_FIT, opticflow_t::max_iterations, opticflow_t::max_track_corners, opticflow_t::median_filter, opticflow_result_t::noise_measurement, opticflow_calc_init(), OPTICFLOW_FOV_H, OPTICFLOW_FOV_W, OPTICFLOW_FX, OPTICFLOW_FY, OPTICFLOW_MAX_TRACK_CORNERS, opticFlowLK(), FloatRates::p, opticflow_t::prev_img_gray, opticflow_t::prev_rates, opticflow_t::prev_timestamp, opticflow_t::pyramid_level, FloatRates::q, opticflow_state_t::rates, SIZE_DIV, opticflow_t::subpixel_factor, linear_flow_fit_info::surface_roughness, opticflow_result_t::surface_roughness, opticflow_t::threshold_vec, timeval_diff(), opticflow_result_t::tracked_cnt, image_t::ts, update_median_filter(), opticflow_result_t::vel_x, opticflow_result_t::vel_y, vel_y_filt, image_t::w, and opticflow_t::window_size.
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 567 of file opticflow_calculator.c.
References calc_edgeflow_tot(), calc_fast9_lukas_kanade(), opticflow_t::just_switched_method, and opticflow_t::method.
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 175 of file opticflow_calculator.c.
References opticflow_t::derotation, opticflow_t::fast9_adaptive, opticflow_t::fast9_min_distance, opticflow_t::fast9_padding, opticflow_t::fast9_ret_corners, opticflow_t::fast9_rsize, opticflow_t::fast9_threshold, FLOAT_RATES_ZERO, opticflow_t::got_first_img, image_create(), IMAGE_GRAYSCALE, opticflow_t::img_gray, init_median_filter(), opticflow_t::max_iterations, opticflow_t::max_track_corners, opticflow_t::median_filter, opticflow_t::method, OPTICFLOW_DEROTATION, OPTICFLOW_FAST9_ADAPTIVE, OPTICFLOW_FAST9_MIN_DISTANCE, OPTICFLOW_FAST9_PADDING, OPTICFLOW_FAST9_THRESHOLD, OPTICFLOW_MAX_ITERATIONS, OPTICFLOW_MAX_TRACK_CORNERS, OPTICFLOW_MEDIAN_FILTER, OPTICFLOW_METHOD, OPTICFLOW_PYRAMID_LEVEL, OPTICFLOW_SEARCH_DISTANCE, OPTICFLOW_SUBPIXEL_FACTOR, OPTICFLOW_THRESHOLD_VEC, OPTICFLOW_WINDOW_SIZE, opticflow_t::prev_img_gray, opticflow_t::prev_rates, opticflow_t::pyramid_level, opticflow_t::search_distance, opticflow_t::subpixel_factor, opticflow_t::threshold_vec, vel_y_filt, and opticflow_t::window_size.
Referenced by calc_fast9_lukas_kanade().