Paparazzi UAS  v7.0_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 "generated/airframe.h"
40 #include <string.h>
41 #include <stdlib.h>
42 #include <stdio.h>
45 #ifndef MAX_HORIZON
46 #define MAX_HORIZON 2
47 #else
48 #if MAX_HORIZON < 2
49 #define MAX_HORIZON 2
50 #endif
51 #endif
52 #ifndef DISP_RANGE_MAX
53 #define DISP_RANGE_MAX 50
54 #endif
55 #ifndef MAX_WINDOW_SIZE
56 #define MAX_WINDOW_SIZE 20
57 #endif
58 #ifndef OPTICFLOW_FOV_W
59 #define OPTICFLOW_FOV_W 0.89360857702
60 #endif
61 #ifndef OPTICFLOW_FOV_H
62 #define OPTICFLOW_FOV_H 0.67020643276
63 #endif
65 struct edge_hist_t {
68  struct timeval frame_time;
69  struct FloatEulers eulers;
70 };
75 };
77 struct edge_flow_t {
82 };
85 // Local functions of the EDGEFLOW algorithm
86 void draw_edgeflow_img(struct image_t *img, struct edge_flow_t edgeflow, int32_t *edge_hist_x_prev
87  , int32_t *edge_hist_x);
88 void calc_previous_frame_nr(struct opticflow_result_t *result, struct opticflow_t *opticflow, uint8_t current_frame_nr,
89  uint8_t *previous_frame_offset, uint8_t *previous_frame_nr);
90 void calculate_edge_histogram(struct image_t *img, int32_t edge_histogram[],
91  char direction, uint16_t edge_threshold);
92 void calculate_edge_displacement(int32_t *edge_histogram, int32_t *edge_histogram_prev, int32_t *displacement,
93  uint16_t size,
94  uint8_t window, uint8_t disp_range, int32_t der_shift);
96 // Local assisting functions (only used here)
97 // TODO: find a way to incorperate/find these functions in paparazzi
98 uint32_t timeval_diff2(struct timeval *starttime, struct timeval *finishtime);
100 void line_fit(int32_t *displacement, int32_t *divergence, int32_t *flow, uint32_t size, uint32_t border,
101  uint16_t RES);
102 uint32_t getAmountPeaks(int32_t *edgehist, int32_t thresh, int32_t size);
105 #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:69
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:66
struct timeval frame_time
Definition: edge_flow.h:68
int32_t div_x
Definition: edge_flow.h:79
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:67
int32_t flow_y
Definition: edge_flow.h:80
uint32_t timeval_diff2(struct timeval *starttime, struct timeval *finishtime)
int32_t div_y
Definition: edge_flow.h:81
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:78
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