Paparazzi UAS
v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
|
calculate optical flow with EdgeFlow More...
#include "std.h"
#include "opticflow/inter_thread_data.h"
#include "lib/vision/image.h"
#include "lib/v4l/v4l2.h"
#include "opticflow/opticflow_calculator.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | edge_hist_t |
struct | edgeflow_displacement_t |
struct | edge_flow_t |
Macros | |
#define | MAX_HORIZON 2 |
#define | DISP_RANGE_MAX 50 |
#define | MAX_WINDOW_SIZE 20 |
#define | OPTICFLOW_FOV_W 0.89360857702 |
#define | OPTICFLOW_FOV_H 0.67020643276 |
Functions | |
void | draw_edgeflow_img (struct image_t *img, struct edge_flow_t edgeflow, int32_t *edge_hist_x_prev, int32_t *edge_hist_x) |
Draws edgehistogram, displacement and linefit directly on the image for debugging (only for edgeflow in horizontal direction!!) More... | |
void | calc_previous_frame_nr (struct opticflow_result_t *result, struct opticflow_t *opticflow, uint8_t current_frame_nr, uint8_t *previous_frame_offset, uint8_t *previous_frame_nr) |
Calc_previous_frame_nr; adaptive Time Horizon. More... | |
void | calculate_edge_histogram (struct image_t *img, int32_t edge_histogram[], char direction, uint16_t edge_threshold) |
Calculate a edge/gradient histogram for each dimension of the image. More... | |
void | calculate_edge_displacement (int32_t *edge_histogram, int32_t *edge_histogram_prev, int32_t *displacement, uint16_t size, uint8_t window, uint8_t disp_range, int32_t der_shift) |
Calculate_displacement calculates the displacement between two histograms. More... | |
uint32_t | timeval_diff2 (struct timeval *starttime, struct timeval *finishtime) |
uint32_t | getMinimum (uint32_t *a, uint32_t n) |
Calculate minimum of an array. More... | |
void | line_fit (int32_t *displacement, int32_t *divergence, int32_t *flow, uint32_t size, uint32_t border, uint16_t RES) |
Fits a linear model to an array with pixel displacements with least squares. More... | |
uint32_t | getAmountPeaks (int32_t *edgehist, uint32_t median, int32_t size) |
getAmountPeaks, calculates the amount of peaks in a edge histogram More... | |
calculate optical flow with EdgeFlow
Edge-histogram matching, implementation by K. N. McGuire Publication: Local Histogram Matching for Efficient Optical Flow Computation Applied to Velocity Estimation on Pocket Drones by K.N. McGuire et al. (2016), ICRA 2016
Definition in file edge_flow.h.
struct edge_hist_t |
Definition at line 64 of file edge_flow.h.
Data Fields | ||
---|---|---|
struct timeval | frame_time | |
struct FloatRates | rates | |
int32_t * | x | |
int32_t * | y |
struct edgeflow_displacement_t |
Definition at line 71 of file edge_flow.h.
Data Fields | ||
---|---|---|
int32_t * | x | |
int32_t * | y |
struct edge_flow_t |
#define DISP_RANGE_MAX 50 |
Definition at line 52 of file edge_flow.h.
Referenced by calc_edgeflow_tot(), and calculate_edge_displacement().
#define MAX_HORIZON 2 |
Definition at line 45 of file edge_flow.h.
Referenced by calc_edgeflow_tot(), and calc_previous_frame_nr().
#define MAX_WINDOW_SIZE 20 |
Definition at line 55 of file edge_flow.h.
Referenced by calc_edgeflow_tot().
#define OPTICFLOW_FOV_H 0.67020643276 |
Definition at line 61 of file edge_flow.h.
#define OPTICFLOW_FOV_W 0.89360857702 |
Definition at line 58 of file edge_flow.h.
void calc_previous_frame_nr | ( | struct opticflow_result_t * | result, |
struct opticflow_t * | opticflow, | ||
uint8_t | current_frame_nr, | ||
uint8_t * | previous_frame_offset, | ||
uint8_t * | previous_frame_nr | ||
) |
Calc_previous_frame_nr; adaptive Time Horizon.
[in] | *opticflow | The opticalflow structure |
[in] | *result | The optical flow result |
[in] | *current_frame_nr | The current frame number of the circular array of the edge_hist struct |
[in] | *previous_frame_offset | previous frame offset of how far the method should compare the edgehistogram |
[out] | *previous_frame_nr | previous frame index of the edgehist struct |
Definition at line 39 of file edge_flow.c.
References opticflow_result_t::flow_x, opticflow_result_t::flow_y, MAX_HORIZON, and opticflow_t::search_distance.
Referenced by calc_edgeflow_tot().
void calculate_edge_displacement | ( | int32_t * | edge_histogram, |
int32_t * | edge_histogram_prev, | ||
int32_t * | displacement, | ||
uint16_t | size, | ||
uint8_t | window, | ||
uint8_t | disp_range, | ||
int32_t | der_shift | ||
) |
Calculate_displacement calculates the displacement between two histograms.
[in] | *edge_histogram | The edge histogram from the current frame_step |
[in] | *edge_histogram_prev | The edge histogram from the previous frame_step |
[in] | *displacement | array with pixel displacement of the sequential edge histograms |
[in] | size | Indicating the size of the displacement array |
[in] | window | Indicating the search window size |
[in] | disp_range | Indicating the maximum disparity range for the block matching |
[in] | der_shift | The pixel shift estimated by the angle rate of the IMU |
Definition at line 168 of file edge_flow.c.
References DISP_RANGE_MAX, and getMinimum().
Referenced by calc_edgeflow_tot().
void calculate_edge_histogram | ( | struct image_t * | img, |
int32_t | edge_histogram[], | ||
char | direction, | ||
uint16_t | edge_threshold | ||
) |
Calculate a edge/gradient histogram for each dimension of the image.
[in] | *img | The image frame to calculate the edge histogram from |
[out] | *edge_histogram | The edge histogram from the current frame_step |
[in] | direction | Indicating if the histogram is made in either x or y direction |
[in] | edge_threshold | A threshold if a gradient is considered a edge or not |
Definition at line 88 of file edge_flow.c.
References image_t::buf.
Referenced by calc_edgeflow_tot().
void draw_edgeflow_img | ( | struct image_t * | img, |
struct edge_flow_t | edgeflow, | ||
int32_t * | edge_hist_x_prev, | ||
int32_t * | edge_hist_x | ||
) |
Draws edgehistogram, displacement and linefit directly on the image for debugging (only for edgeflow in horizontal direction!!)
[out] | *img | The image structure where will be drawn on |
[in] | edgeflow | Information structure for flow information |
[in] | Displacement | Pixel wise Displacement array |
[in] | *edge_hist_x | Horizontal edge_histogram |
Definition at line 301 of file edge_flow.c.
References edge_flow_t::div_x, edge_flow_t::flow_x, image_t::h, image_draw_line(), image_t::w, point_t::x, and point_t::y.
Referenced by calc_edgeflow_tot().
getAmountPeaks, calculates the amount of peaks in a edge histogram
[in] | *edgehist | Horizontal edge_histogram |
[in] | thres | The threshold from which a peak is considered significant peak or not |
[in] | size | Size of the array |
return] | amount of peaks |
Definition at line 341 of file edge_flow.c.
Referenced by calc_edgeflow_tot().
Calculate minimum of an array.
[in] | *a | Array containing values |
[in] | *n | The size of the array |
Definition at line 224 of file edge_flow.c.
Referenced by calculate_edge_displacement().
void line_fit | ( | int32_t * | displacement, |
int32_t * | divergence, | ||
int32_t * | flow, | ||
uint32_t | size, | ||
uint32_t | border, | ||
uint16_t | RES | ||
) |
Fits a linear model to an array with pixel displacements with least squares.
[in] | *displacements | Array with Pixel Displacements |
[out] | *divergence | Global divergence of pixel displacements |
[out] | *flow | Global translational flow from pixel displacements |
[in] | *size | Size of displacement array |
[in] | border | A border offset of the array that should not be considerd for the line fit |
[in] | RES | Resolution to be used for the integer based linefit |
Definition at line 251 of file edge_flow.c.
Referenced by calc_edgeflow_tot().
uint32_t timeval_diff2 | ( | struct timeval * | starttime, |
struct timeval * | finishtime | ||
) |