Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
edge_flow.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Kimberly McGuire <k.n.mcguire@tudelft.nl
3  *
4  * This file is part of Paparazzi.
5  *
6  * Paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * Paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
30 #ifndef EDGE_FLOW_H_
31 #define EDGE_FLOW_H_
32 
33 
34 #include "std.h"
36 #include "lib/vision/image.h"
37 #include "lib/v4l/v4l2.h"
39 #include <string.h>
40 #include <stdlib.h>
41 #include <stdio.h>
42 
43 
44 #ifndef MAX_HORIZON
45 #define MAX_HORIZON 2
46 #else
47 #if MAX_HORIZON < 2
48 #define MAX_HORIZON 2
49 #endif
50 #endif
51 #ifndef DISP_RANGE_MAX
52 #define DISP_RANGE_MAX 50
53 #endif
54 #ifndef MAX_WINDOW_SIZE
55 #define MAX_WINDOW_SIZE 20
56 #endif
57 #ifndef OPTICFLOW_FOV_W
58 #define OPTICFLOW_FOV_W 0.89360857702
59 #endif
60 #ifndef OPTICFLOW_FOV_H
61 #define OPTICFLOW_FOV_H 0.67020643276
62 #endif
63 
64 struct edge_hist_t {
67  struct timeval frame_time;
69 };
70 
74 };
75 
76 struct edge_flow_t {
81 };
82 
83 
84 // Local functions of the EDGEFLOW algorithm
85 void draw_edgeflow_img(struct image_t *img, struct edge_flow_t edgeflow, int32_t *edge_hist_x_prev
86  , int32_t *edge_hist_x);
87 void calc_previous_frame_nr(struct opticflow_result_t *result, struct opticflow_t *opticflow, uint8_t current_frame_nr,
88  uint8_t *previous_frame_offset, uint8_t *previous_frame_nr);
89 void calculate_edge_histogram(struct image_t *img, int32_t edge_histogram[],
90  char direction, uint16_t edge_threshold);
91 void calculate_edge_displacement(int32_t *edge_histogram, int32_t *edge_histogram_prev, int32_t *displacement,
92  uint16_t size,
93  uint8_t window, uint8_t disp_range, int32_t der_shift);
94 
95 // Local assisting functions (only used here)
96 // TODO: find a way to incorperate/find these functions in paparazzi
97 uint32_t timeval_diff2(struct timeval *starttime, struct timeval *finishtime);
99 void line_fit(int32_t *displacement, int32_t *divergence, int32_t *flow, uint32_t size, uint32_t border,
100  uint16_t RES);
101 uint32_t getAmountPeaks(int32_t *edgehist, int32_t thresh, int32_t size);
102 
103 
104 #endif /* EDGE_FLOW_H_ */
unsigned short uint16_t
Definition: types.h:16
int32_t flow_x
Definition: edge_flow.h:77
struct opticflow_t opticflow
Opticflow calculations.
Capture images from a V4L2 device (Video for Linux 2)
Calculate velocity from optic flow.
Definition: image.h:43
int32_t div_x
Definition: edge_flow.h:78
int32_t * y
Definition: edge_flow.h:66
int32_t flow_y
Definition: edge_flow.h:79
#define RES
Definition: detect_window.c:27
Inter-thread data structures.
uint32_t timeval_diff2(struct timeval *starttime, struct timeval *finishtime)
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 ...
Definition: edge_flow.c:297
euler angles
Image helper functions like resizing, color filter, converters...
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.
Definition: edge_flow.c:247
uint32_t getAmountPeaks(int32_t *edgehist, int32_t thresh, int32_t size)
getAmountPeaks, calculates the amount of peaks in a edge histogram
Definition: edge_flow.c:337
unsigned long uint32_t
Definition: types.h:18
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.
Definition: edge_flow.c:88
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.
Definition: edge_flow.c:168
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.
Definition: edge_flow.c:39
signed long int32_t
Definition: types.h:19
uint32_t getMinimum(uint32_t *a, uint32_t n)
Calculate minimum of an array.
Definition: edge_flow.c:220
unsigned char uint8_t
Definition: types.h:14
struct FloatEulers eulers
Definition: edge_flow.h:68
uint8_t direction
int32_t div_y
Definition: edge_flow.h:80
struct timeval frame_time
Definition: edge_flow.h:67
int32_t * x
Definition: edge_flow.h:65