![]() |
Paparazzi UAS
v5.8.2_stable-0-g6260b7c
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... | |
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 37 of file opticflow_calculator.h.
Data Fields | ||
---|---|---|
bool_t | fast9_adaptive | Whether the FAST9 threshold should be adaptive. |
uint16_t | fast9_min_distance | Minimum distance in pixels between corners. |
uint8_t | fast9_threshold | FAST9 corner detection threshold. |
bool_t | got_first_img | If we got a image to work with. |
struct image_t | img_gray | Current gray image frame. |
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. |
struct image_t | prev_img_gray | Previous gray image frame. |
float | prev_phi | Phi from the previous image frame. |
float | prev_theta | Theta from the previous image frame. |
struct timeval | prev_timestamp | Timestamp of the previous frame, used for FPS calculation. |
uint8_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 of the Lucas Kanade calculation (needs to be even) |
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().