Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
colorfilter.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015
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, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
26 // Own header
28 #include <stdio.h>
29 
31 
32 #ifndef COLORFILTER_FPS
33 #define COLORFILTER_FPS 0
34 #endif
35 PRINT_CONFIG_VAR(COLORFILTER_FPS)
36 
37 
38 #ifndef COLORFILTER_SEND_OBSTACLE
39 #define COLORFILTER_SEND_OBSTACLE FALSE
40 #endif
41 PRINT_CONFIG_VAR(COLORFILTER_SEND_OBSTACLE)
42 
43 struct video_listener *listener = NULL;
44 
45 // Filter Settings
52 
53 // Result
54 volatile int color_count = 0;
55 
56 #include "modules/core/abi.h"
57 
58 // Function
59 static struct image_t *colorfilter_func(struct image_t *img, uint8_t camera_id __attribute__((unused)))
60 {
61  // Filter
66  );
67 
69  if (color_count > 20)
70  {
71  AbiSendMsgOBSTACLE_DETECTION(OBS_DETECTION_COLOR_ID, 1.f, 0.f, 0.f);
72  }
73  else
74  {
75  AbiSendMsgOBSTACLE_DETECTION(OBS_DETECTION_COLOR_ID, 10.f, 0.f, 0.f);
76  }
77  }
78 
79  return img; // Colorfilter did not make a new image
80 }
81 
82 void colorfilter_init(void)
83 {
84  cv_add_to_device(&COLORFILTER_CAMERA, colorfilter_func, COLORFILTER_FPS, 0);
85 }
uint8_t
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98
colorfilter_func
static struct image_t * colorfilter_func(struct image_t *img, uint8_t camera_id)
Definition: colorfilter.c:59
color_count
volatile int color_count
Definition: colorfilter.c:54
color_lum_max
uint8_t color_lum_max
Definition: colorfilter.c:47
colorfilter.h
cv_add_to_device
struct video_listener * cv_add_to_device(struct video_config_t *device, cv_function func, uint16_t fps, uint8_t id)
Definition: cv.c:46
COLORFILTER_FPS
#define COLORFILTER_FPS
Default FPS (zero means run at camera fps)
Definition: colorfilter.c:33
color_cb_max
uint8_t color_cb_max
Definition: colorfilter.c:49
listener
struct video_listener * listener
Definition: colorfilter.c:43
COLORFILTER_SEND_OBSTACLE
#define COLORFILTER_SEND_OBSTACLE
Default sonar/agl to use in opticflow visual_estimator.
Definition: colorfilter.c:39
OBS_DETECTION_COLOR_ID
#define OBS_DETECTION_COLOR_ID
Definition: abi_sender_ids.h:462
image_yuv422_colorfilt
uint16_t image_yuv422_colorfilt(struct image_t *input, struct image_t *output, uint8_t y_m, uint8_t y_M, uint8_t u_m, uint8_t u_M, uint8_t v_m, uint8_t v_M)
Filter colors in an YUV422 image.
Definition: image.c:173
image.h
f
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
Definition: wedgebug.c:204
color_cr_max
uint8_t color_cr_max
Definition: colorfilter.c:51
colorfilter_init
void colorfilter_init(void)
Definition: colorfilter.c:82
color_cr_min
uint8_t color_cr_min
Definition: colorfilter.c:50
color_lum_min
uint8_t color_lum_min
Definition: colorfilter.c:46
video_listener
Definition: cv.h:51
color_cb_min
uint8_t color_cb_min
Definition: colorfilter.c:48
image_t
Definition: image.h:44