Paparazzi UAS  v6.3_unstable
Paparazzi is a free software Unmanned Aircraft System.
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Kimberly McGuire <
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
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  * <>.
19  */
30 #ifndef EDGE_FLOW_H_
31 #define EDGE_FLOW_H_
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>
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
64 struct edge_hist_t {
67  struct timeval frame_time;
68  struct FloatEulers eulers;
69 };
74 };
76 struct edge_flow_t {
81 };
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);
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);
104 #endif /* EDGE_FLOW_H_ */
#define RES
Definition: detect_window.c:27
uint32_t getMinimum(uint32_t *a, uint32_t n)
Calculate minimum of an array.
Definition: edge_flow.c:220
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 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
struct FloatEulers eulers
Definition: edge_flow.h:68
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 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
int32_t * x
Definition: edge_flow.h:65
struct timeval frame_time
Definition: edge_flow.h:67
int32_t div_x
Definition: edge_flow.h:78
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
int32_t * y
Definition: edge_flow.h:66
int32_t flow_y
Definition: edge_flow.h:79
uint32_t timeval_diff2(struct timeval *starttime, struct timeval *finishtime)
int32_t div_y
Definition: edge_flow.h:80
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
int32_t flow_x
Definition: edge_flow.h:77
euler angles
Image helper functions like resizing, color filter, converters...
Definition: image.h:44
Inter-thread data structures.
uint8_t direction
Calculate velocity from optic flow.
struct opticflow_t opticflow[ACTIVE_CAMERAS]
Opticflow calculations.
Capture images from a V4L2 device (Video for Linux 2)
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
Definition: vl53l1_types.h:88
int int32_t
Typedef defining 32 bit int type.
Definition: vl53l1_types.h:83
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98