[computer_vision] Sample cv module

This commit is contained in:
Christophe De Wagter
2015-09-06 20:54:20 +02:00
parent 6de8beba98
commit 3bbce540df
3 changed files with 138 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="ColorFilter" dir="computer_vision">
<doc>
<description>ColorFilter</description>
</doc>
<settings>
<dl_settings>
<dl_settings NAME="ColorFilter">
<dl_setting var="color_lum_min" min="0" step="1" max="255" shortname="y_min" />
<dl_setting var="color_lum_max" min="0" step="1" max="255" shortname="y_max" />
<dl_setting var="color_cb_min" min="0" step="1" max="255" shortname="u_min" />
<dl_setting var="color_cb_max" min="0" step="1" max="255" shortname="u_max" />
<dl_setting var="color_cr_min" min="0" step="1" max="255" shortname="v_min" />
<dl_setting var="color_cr_max" min="0" step="1" max="255" shortname="v_max" />
</dl_settings>
</dl_settings>
</settings>
<depends>video_thread</depends>
<header>
<file name="colorfilter.h"/>
</header>
<init fun="colorfilter_init()"/>
<makefile>
<file name="colorfilter.c"/>
</makefile>
</module>
@@ -0,0 +1,61 @@
/*
* Copyright (C) 2015
*
* This file is part of Paparazzi.
*
* Paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* @file modules/computer_vision/colorfilter.c
*/
// Own header
#include "modules/computer_vision/cv.h"
#include "modules/computer_vision/colorfilter.h"
#include <stdio.h>
// Filter Settings
uint8_t color_lum_min = 105;
uint8_t color_lum_max = 205;
uint8_t color_cb_min = 52;
uint8_t color_cb_max = 140;
uint8_t color_cr_min = 180;
uint8_t color_cr_max = 255;
// Result
int color_count = 0;
// Function
bool_t colorfilter_func(struct image_t* img);
bool_t colorfilter_func(struct image_t* img)
{
// Filter
color_count = image_yuv422_colorfilt(img,img,
color_lum_min,color_lum_max,
color_cb_min,color_cb_max,
color_cr_min,color_cr_max
);
return FALSE;
}
void colorfilter_init(void)
{
cv_add(colorfilter_func);
}
@@ -0,0 +1,45 @@
/*
* Copyright (C) 2015
*
* This file is part of Paparazzi.
*
* Paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* Paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* @file modules/computer_vision/colorfilter.h
*/
#ifndef COLORFILTER_CV_PLUGIN_H
#define COLORFILTER_CV_PLUGIN_H
#include <stdint.h>
// Module functions
extern void colorfilter_init(void);
extern uint8_t color_lum_min;
extern uint8_t color_lum_max;
extern uint8_t color_cb_min;
extern uint8_t color_cb_max;
extern uint8_t color_cr_min;
extern uint8_t color_cr_max;
extern int color_count;
#endif /* COLORFILTER_CV_PLUGIN_H */