Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
edge_flow.c File Reference

calculate optical flow with EdgeFlow More...

+ Include dependency graph for edge_flow.c:

Go to the source code of this file.

Functions

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 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...
 
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...
 
uint32_t getAmountPeaks (int32_t *edgehist, int32_t thres, int32_t size)
 getAmountPeaks, calculates the amount of peaks in a edge histogram More...
 

Detailed Description

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.c.

Function Documentation

◆ calc_previous_frame_nr()

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.

Parameters
[in]*opticflowThe opticalflow structure
[in]*resultThe optical flow result
[in]*current_frame_nrThe current frame number of the circular array of the edge_hist struct
[in]*previous_frame_offsetprevious frame offset of how far the method should compare the edgehistogram
[out]*previous_frame_nrprevious 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, opticflow, and opticflow_t::search_distance.

Referenced by calc_edgeflow_tot().

+ Here is the caller graph for this function:

◆ calculate_edge_displacement()

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.

Parameters
[in]*edge_histogramThe edge histogram from the current frame_step
[in]*edge_histogram_prevThe edge histogram from the previous frame_step
[out]*displacementarray with pixel displacement of the sequential edge histograms
[in]sizeIndicating the size of the displacement array
[in]windowIndicating the search window size
[in]disp_rangeIndicating the maximum disparity range for the block matching
[in]der_shiftThe pixel shift estimated by the angle rate of the IMU

Definition at line 168 of file edge_flow.c.

References D, DISP_RANGE_MAX, and getMinimum().

Referenced by calc_edgeflow_tot().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ calculate_edge_histogram()

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.

Parameters
[in]*imgThe image frame to calculate the edge histogram from
[out]*edge_histogramThe edge histogram from the current frame_step
[in]directionIndicating if the histogram is made in either x or y direction
[in]edge_thresholdA 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().

+ Here is the caller graph for this function:

◆ draw_edgeflow_img()

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!!)

Parameters
[out]*imgThe image structure where will be drawn on
[in]edgeflowInformation structure for flow information
[in]DisplacementPixel wise Displacement array
[in]*edge_hist_xHorizontal edge_histogram

Definition at line 297 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAmountPeaks()

uint32_t getAmountPeaks ( int32_t edgehist,
int32_t  thres,
int32_t  size 
)

getAmountPeaks, calculates the amount of peaks in a edge histogram

Parameters
[in]*edgehistHorizontal edge_histogram
[in]thresThe threshold from which a peak is considered significant peak or not
[in]sizeSize of the array
[return]amount of peaks

Definition at line 337 of file edge_flow.c.

Referenced by calc_edgeflow_tot().

+ Here is the caller graph for this function:

◆ getMinimum()

uint32_t getMinimum ( uint32_t a,
uint32_t  n 
)

Calculate minimum of an array.

Parameters
[in]*aArray containing values
[in]*nThe size of the array
Returns
The index of the smallest value of the array

Definition at line 220 of file edge_flow.c.

Referenced by calculate_edge_displacement().

+ Here is the caller graph for this function:

◆ line_fit()

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.

Parameters
[in]*displacementsArray with Pixel Displacements
[out]*divergenceGlobal divergence of pixel displacements
[out]*flowGlobal translational flow from pixel displacements
[in]*sizeSize of displacement array
[in]borderA border offset of the array that should not be considerd for the line fit
[in]RESResolution to be used for the integer based linefit

Definition at line 247 of file edge_flow.c.

References RES.

Referenced by calc_edgeflow_tot().

+ Here is the caller graph for this function: