Skip to content

Commit

Permalink
[blob] switch algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
dewagter committed Sep 14, 2015
1 parent 76d5e65 commit 2542259
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 6 deletions.
17 changes: 11 additions & 6 deletions conf/modules/cv_blob_locator.xml
Expand Up @@ -7,15 +7,19 @@
<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_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_setting var="cv_blob_locator_reset" max="1" min="0" step="1" module="computer_vision/cv_blob_locator" handler="GeoReset">
<strip_button name="Reset" value="1" />
</dl_setting>
<dl_setting var="cv_blob_locator_type" min="0" step="1" max="1" module="computer_vision/cv_blob_locator" values="BLOB|IMAVMARKER">
<strip_button name="POWER ON" icon="on.png" value="1" group="power_switch"/>
<strip_button name="POWER OFF" icon="off.png" value="0" group="power_switch"/>
</dl_setting>
</dl_settings>
</dl_settings>
</settings>
Expand All @@ -30,6 +34,7 @@
<event fun="cv_blob_locator_event()"/>
<makefile>
<file name="cv_blob_locator.c"/>
<file name="imavmarker.c" dir="modules/computer_vision/blob" />
<file name="blob_finder.c" dir="modules/computer_vision/blob" />
<file name="cv_georeference.c" dir="modules/computer_vision/" />
</makefile>
Expand Down
9 changes: 9 additions & 0 deletions sw/airborne/modules/computer_vision/blob/imavmarker.c
Expand Up @@ -35,6 +35,8 @@
* @return The deviation of the marker location wrt the center.
*/

bool_t marker_enabled = TRUE;


#define Img(X,Y)(source[(Y)*input->w*2+(X)*2+1])
#define Out(X,Y)(source[(Y)*input->w*2+(X)*2])
Expand All @@ -52,6 +54,13 @@ struct marker_deviation_t marker(struct image_t *input, uint8_t M)
{
struct marker_deviation_t marker_deviation;

marker_deviation.x = 0;
marker_deviation.y = 0;
marker_deviation.inlier = 0;

if (! marker_enabled)
return marker_deviation;

uint8_t *source = (uint8_t *) input->buf;
uint16_t x, y, i, j, k;

Expand Down
2 changes: 2 additions & 0 deletions sw/airborne/modules/computer_vision/blob/imavmarker.h
Expand Up @@ -35,4 +35,6 @@ struct marker_deviation_t {
};


extern bool_t marker_enabled;

struct marker_deviation_t marker(struct image_t *input, uint8_t M);
20 changes: 20 additions & 0 deletions sw/airborne/modules/computer_vision/cv_blob_locator.c
Expand Up @@ -26,6 +26,7 @@
#include "modules/computer_vision/cv_blob_locator.h"
#include "modules/computer_vision/cv.h"
#include "modules/computer_vision/blob/blob_finder.h"
#include "modules/computer_vision/blob/imavmarker.h"


uint8_t color_lum_min;
Expand All @@ -38,13 +39,22 @@ uint8_t color_cr_min;
uint8_t color_cr_max;

uint8_t cv_blob_locator_reset;
uint8_t cv_blob_locator_type;

volatile uint32_t blob_locator = 0;

volatile bool_t blob_enabled = FALSE;

// Computer vision thread
bool_t cv_blob_locator_func(struct image_t *img);
bool_t cv_blob_locator_func(struct image_t *img) {

blob_enabled = ! marker_enabled;

if (!blob_enabled)
return FALSE;


// Color Filter
struct image_filter_t filter[2];
filter[0].y_min = color_lum_min;
Expand Down Expand Up @@ -168,6 +178,16 @@ void cv_blob_locator_periodic(void) {


void cv_blob_locator_event(void) {
if (cv_blob_locator_type == 1)
{
blob_enabled = TRUE;
marker_enabled = FALSE;
}
else
{
blob_enabled = FALSE;
marker_enabled = TRUE;
}
if (blob_locator != 0) {
// CV thread has results: import
uint32_t temp = blob_locator;
Expand Down
1 change: 1 addition & 0 deletions sw/airborne/modules/computer_vision/cv_blob_locator.h
Expand Up @@ -38,6 +38,7 @@ extern uint8_t color_cr_min;
extern uint8_t color_cr_max;

extern uint8_t cv_blob_locator_reset;
extern uint8_t cv_blob_locator_type;

extern void cv_blob_locator_init(void);
extern void cv_blob_locator_periodic(void);
Expand Down

0 comments on commit 2542259

Please sign in to comment.