Paparazzi UAS  v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
edge_flow.h File Reference

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>
+ Include dependency graph for edge_flow.h:
+ This graph shows which files directly or indirectly include this file:

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, int32_t thresh, 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.h.


Data Structure Documentation

struct edge_hist_t

Definition at line 64 of file edge_flow.h.

+ Collaboration diagram for edge_hist_t:
Data Fields
struct FloatEulers eulers
struct timeval frame_time
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

Definition at line 76 of file edge_flow.h.

Data Fields
int32_t div_x
int32_t div_y
int32_t flow_x
int32_t flow_y

Macro Definition Documentation

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

Function Documentation

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, and opticflow_t::search_distance.

Referenced by calc_edgeflow_tot().

+ Here is the caller graph for this function:

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:

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:

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:

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:

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:

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.

Referenced by calc_edgeflow_tot().

+ Here is the caller graph for this function:

uint32_t timeval_diff2 ( struct timeval *  starttime,
struct timeval *  finishtime 
)