Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
futbot
futbot2014
Commits
774bc15a
Commit
774bc15a
authored
Oct 25, 2014
by
Aylen Ricca
Browse files
merging ...
parents
e766e506
e2f533ee
Changes
43
Expand all
Hide whitespace changes
Inline
Side-by-side
visrob2/example/IntegradoWEB/CMakeLists.txt
View file @
774bc15a
...
...
@@ -15,6 +15,15 @@ set_property(TARGET libICamera PROPERTY IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE
add_library
(
libvision STATIC IMPORTED
)
set_property
(
TARGET libvision PROPERTY IMPORTED_LOCATION
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../lib/libvision.a
)
add_library
(
libConfiguracion STATIC IMPORTED
)
set_property
(
TARGET libConfiguracion PROPERTY IMPORTED_LOCATION
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../lib/libConfiguracion.a
)
add_library
(
libconfuse STATIC IMPORTED
)
set_property
(
TARGET libconfuse PROPERTY IMPORTED_LOCATION
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../libinclude/libconfuse.a
)
set_source_files_properties
(
main.c PROPERTIES LANGUAGE CXX
)
...
...
@@ -22,6 +31,6 @@ add_executable(integrationTest main.c)
SET_TARGET_PROPERTIES
(
integrationTest PROPERTIES LINKER_LANGUAGE CXX
)
target_link_libraries
(
integrationTest libvision libICamera
${
LIBS
}
-lm
)
target_link_libraries
(
integrationTest libvision libICamera
libConfiguracion libconfuse
${
LIBS
}
-lm
)
INSTALL
(
TARGETS integrationTest DESTINATION
${
CMAKE_CURRENT_SOURCE_DIR
}
)
\ No newline at end of file
visrob2/example/IntegradoWEB/futbotVision.conf
0 → 100644
View file @
774bc15a
# regiones a detectar por el modulo vision -calibraciones
region
ball
{
id
=
0
hsiMin
={
11
,
207
,
81
}
hsiMax
={
19
,
255
,
202
}
}
region
field
{
id
=
1
hsiMin
={
25
,
7
,
125
}
hsiMax
={
33
,
31
,
32
}
}
region
my_goal
{
id
=
2
hsiMin
={
21
,
208
,
82
}
hsiMax
={
24
,
253
,
145
}
}
region
opp_goal
{
id
=
3
hsiMin
={
107
,
58
,
44
}
hsiMax
={
118
,
142
,
55
}
}
region
robot_body
{
id
=
4
hsiMin
={
0
,
0
,
19
}
hsiMax
={
0
,
0
,
22
}
}
region
cyan
{
id
=
5
hsiMin
={
0
,
0
,
0
}
hsiMax
={
0
,
0
,
0
}
}
region
magenta
{
id
=
6
hsiMin
={-
24
,
41
,
24
}
hsiMax
={
6
,
215
,
115
}
}
visrob2/example/IntegradoWEB/main.c
View file @
774bc15a
...
...
@@ -6,13 +6,33 @@
############################################################*/
#include "vision.h"
#include <stdio.h>
#include <stdio.h>
int
main
()
{
if
(
!
vision_initialize
(
DEFAULT_HAVIMO_ID
,
DEFAULT_BAUDNUM
,
CYAN
_COLOR
))
if
(
!
vision_initialize
(
DEFAULT_HAVIMO_ID
,
DEFAULT_BAUDNUM
,
MAGENTA
_COLOR
))
return
-
1
;
vision_checkVision
(
0
);
if
(
vision_checkVision
(
0
))
{
unsigned
short
int
i
;
char
buffer
[
33
];
for
(
i
=
0
;
i
<
obj_size
;
i
++
)
{
printf
(
"::"
);
printf
(
"%hu"
,
objects
[
i
].
type
);
printf
(
" "
);
printf
(
"%d"
,
objects
[
i
].
x
);
printf
(
" "
);
printf
(
"%u"
,
objects
[
i
].
y
);
printf
(
" "
);
printf
(
"%u"
,
objects
[
i
].
z
);
printf
(
" "
);
printf
(
"%hu"
,
objects
[
i
].
likeness_level
);
printf
(
"
\n
"
);
}
}
printf
(
"---
\n
"
);
vision_terminate
();
printf
(
"
FINAL FELIZ...
\n
"
);
printf
(
"
THE END!
\n
"
);
return
0
;
}
visrob2/example/IntegradoWEB/main.c_old
0 → 100644
View file @
774bc15a
/*############################################################
# #
# Proyecto Futbol de Robots. - PAIE 2014 #
# http://www.fing.edu.uy/inco/proyectos/futbot13/ #
# #
############################################################*/
#include "vision.h"
#include <stdio.h>
int main() {
if (!vision_initialize(DEFAULT_HAVIMO_ID, DEFAULT_BAUDNUM, CYAN_COLOR))
return -1;
vision_checkVision(0);
vision_terminate();
printf("FINAL FELIZ...\n");
return 0;
}
visrob2/example/ejCAMVISCONF/clasification.c
0 → 100644
View file @
774bc15a
/*############################################################
# #
# Proyecto Visión robótica y reconstrucción espacial #
# con aplicaciones prácticas. 2010 #
# http://www.fing.edu.uy/inco/grupos/mina/pGrado/vision2010 #
# #
############################################################*/
#include "clasification.h"
#include "iVisionModule.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
//#include <util/delay.h>
int
HaViMo_id
;
/**
* Verifica si 2 blobs pueden ser combinados. Retorna la posicion del blob a, de acuerdo al blob b
* a blob para comparar con b
* b blob para comparar con a
* x_threshold umbral para la comparacion en el eje x
* y_threshold umbral para la comparacion en el eje y
* Retorna:
* 0 No pueden ser combinados
* 1 A arriba de B
* 2 A debajo B
* 3 A a la izquierda de B
* 4 A a la derecha de B
*/
int
vision_cla_canBlobsBeMerged
(
struct
blob
a
,
struct
blob
b
,
unsigned
int
x_threshold
,
unsigned
int
y_threshold
)
{
if
((
abs
(
a
.
min_x
-
b
.
min_x
)
<
x_threshold
)
&&
(
abs
(
a
.
max_x
-
b
.
max_x
)
<
x_threshold
))
{
//A TOP B
if
(
abs
(
a
.
max_y
-
b
.
min_y
)
<
y_threshold
)
return
1
;
//A BOT B
if
(
abs
(
a
.
min_y
-
b
.
max_y
)
<
y_threshold
)
return
2
;
}
if
((
abs
(
a
.
min_y
-
b
.
min_y
)
<
y_threshold
)
&&
(
abs
(
a
.
max_y
-
b
.
max_y
)
<
y_threshold
))
{
//A LEFT B
if
(
abs
(
a
.
max_x
-
b
.
min_x
)
<
x_threshold
)
return
3
;
//A RIGHT B
if
(
abs
(
a
.
min_x
-
b
.
max_x
)
<
x_threshold
)
return
4
;
}
return
0
;
}
/**
* Inicializa las estructuras que utiliza la clasificacion, inicializando iHaViMo.
* HaViMo_dxl_ID identificador dynamixel de havimo
* baudnum baudnum con que se incializara la libreria dynamixel
*/
int
vision_cls_initialize
(
int
HaViMo_dxl_ID
,
int
baudnum
)
{
HaViMo_id
=
HaViMo_dxl_ID
;
return
iVisionModule_initialize
(
HaViMo_dxl_ID
,
baudnum
);
}
/**
* Mergear los blobs, a partir de un region_color especifico, usando como umbral GOAL_THRESHOLD_X y GOAL_THRESHOLD_Y
* blobs blobs a mergear
* region_color color que se debe mergear
* dont_process_blob array que define si no se debe procesar un blob
*/
void
vision_cls_mergeGoalBlobsByRegion
(
struct
blob
*
blobs
,
short
int
region_color
,
unsigned
short
int
*
dont_process_blob
)
{
//Preprocesamiento del array de blobs
unsigned
short
int
i
;
unsigned
short
int
j
;
unsigned
short
int
blobs_merged
;
do
{
blobs_merged
=
0
;
for
(
i
=
0
;
i
<
CANT_REGIONS
;
i
++
)
{
if
(
blobs
[
i
].
region_index
!=
INVALID_REGION
&&
blobs
[
i
].
region_color
==
region_color
&&
!
dont_process_blob
[
i
])
{
for
(
j
=
i
+
1
;
j
<
CANT_REGIONS
;
j
++
)
{
if
(
!
dont_process_blob
[
j
]
&&
blobs
[
j
].
region_index
!=
INVALID_REGION
&&
blobs
[
i
].
region_color
==
blobs
[
j
].
region_color
&&
vision_cla_canBlobsBeMerged
(
blobs
[
i
],
blobs
[
j
],
GOAL_THRESHOLD_X
,
GOAL_THRESHOLD_Y
))
{
//Se combinan los blobs
blobs
[
j
].
region_index
=
0
;
if
(
blobs
[
i
].
max_x
<
blobs
[
j
].
max_x
)
blobs
[
i
].
max_x
=
blobs
[
j
].
max_x
;
if
(
blobs
[
i
].
min_x
>
blobs
[
j
].
min_x
)
blobs
[
i
].
min_x
=
blobs
[
j
].
min_x
;
if
(
blobs
[
i
].
max_y
<
blobs
[
j
].
max_y
)
blobs
[
i
].
max_y
=
blobs
[
j
].
max_y
;
if
(
blobs
[
i
].
min_y
>
blobs
[
j
].
min_y
)
blobs
[
i
].
min_y
=
blobs
[
j
].
min_y
;
blobs_merged
=
1
;
}
}
}
}
}
while
(
blobs_merged
);
}
/**
* Retorna el preprocesamiento realizado sobre el resultado de la segmentacion de la imagen de HaViMo.
* Si no hay un nuevo frame para procesar se retorna NULL.
* force_frame fuerza la obtencion del frame.
*/
struct
blob
*
vision_cls_getNextFrame
(
unsigned
short
int
force_frame
)
{
struct
blob
*
blobs
=
iVisionModule_getNextFrame
(
HaViMo_id
);
if
(
force_frame
)
{
while
(
blobs
==
NULL
){
//_delay_ms(FORCE_FRAME_MS_DELAY);
blobs
=
iVisionModule_getNextFrame
(
HaViMo_id
);
}
}
else
{
if
(
blobs
==
NULL
)
{
printf
(
"null blobs
\n
"
);
return
NULL
;
}
}
//Preprocesamiento del array de blobs
unsigned
short
int
i
;
unsigned
short
int
j
;
unsigned
short
int
blobs_merged
;
do
{
blobs_merged
=
0
;
for
(
i
=
0
;
i
<
CANT_REGIONS
;
i
++
)
{
printf
(
"procesar
\n
"
);
if
(
blobs
[
i
].
region_index
!=
INVALID_REGION
)
{
printf
(
"no es invalida
\n
"
);
if
(
blobs
[
i
].
max_x
-
blobs
[
i
].
min_x
<=
MIN_PX_SIZE_FOR_BLOB
||
blobs
[
i
].
max_y
-
blobs
[
i
].
min_y
<=
MIN_PX_SIZE_FOR_BLOB
)
{
//Invalidamos el blob
printf
(
"invalido blobs
\n
"
);
blobs
[
i
].
region_index
=
INVALID_REGION
;
}
else
{
for
(
j
=
i
+
1
;
j
<
CANT_REGIONS
;
j
++
)
{
if
(
blobs
[
j
].
region_index
!=
INVALID_REGION
&&
blobs
[
i
].
region_color
==
blobs
[
j
].
region_color
&&
vision_cla_canBlobsBeMerged
(
blobs
[
i
],
blobs
[
j
],
THRESHOLD_X
,
THRESHOLD_Y
))
{
//Se combinan los blobs
printf
(
"blobs combinados
\n
"
);
blobs
[
j
].
region_index
=
INVALID_REGION
;
if
(
blobs
[
i
].
max_x
<
blobs
[
j
].
max_x
)
blobs
[
i
].
max_x
=
blobs
[
j
].
max_x
;
if
(
blobs
[
i
].
min_x
>
blobs
[
j
].
min_x
)
blobs
[
i
].
min_x
=
blobs
[
j
].
min_x
;
if
(
blobs
[
i
].
max_y
<
blobs
[
j
].
max_y
)
blobs
[
i
].
max_y
=
blobs
[
j
].
max_y
;
if
(
blobs
[
i
].
min_y
>
blobs
[
j
].
min_y
)
blobs
[
i
].
min_y
=
blobs
[
j
].
min_y
;
blobs
[
i
].
number_of_pixels
+=
blobs
[
j
].
number_of_pixels
;
blobs_merged
=
1
;
}
}
}
}
else
printf
(
"es invalida
\n
"
);
}
}
while
(
blobs_merged
);
return
blobs
;
}
/**
* Finaliza clasificacion. Finaliza iHaViMo.
*/
void
vision_cls_terminate
(
void
)
{
iVisionModule_terminate
();
}
visrob2/example/ejCAMVISCONF/clasification.h
0 → 100644
View file @
774bc15a
/*############################################################
# #
# Proyecto Visión robótica y reconstrucción espacial #
# con aplicaciones prácticas. 2010 #
# http://www.fing.edu.uy/inco/grupos/mina/pGrado/vision2010 #
# #
############################################################*/
/**
* clasification.h: Modulo de clasificacion de la capa de Vision.
* Encargado del preprocesamiento de los blobs obtenidos de HaViMo.
* @author: Gonzalo Gismero
*/
#ifndef I_VISION_CLASIFICATION
#define I_VISION_CLASIFICATION
#include "iVisionModule.h"
#define MIN_PX_SIZE_FOR_BLOB 2//Quitamos los blobs que tengan un ancho o largo de 2 pixeles
#define FORCE_FRAME_MS_DELAY 10 //miliseconds
#define THRESHOLD_Y 7//10 //px
#define THRESHOLD_X 7//10 //px
//Luego del identificar los blobs de los landmarks, se intenta juntar los blobs que sobraron para los arcos con un umbral mayor
#define GOAL_THRESHOLD_X 15//px
#define GOAL_THRESHOLD_Y 15//px
/**
* Inicializa las estructuras que utiliza la clasificacion, inicializando iHaViMo.
* HaViMo_dxl_ID identificador dynamixel de havimo
* baudnum baudnum con que se incializara la libreria dynamixel
*/
int
vision_cls_initialize
(
int
HaViMo_dxl_ID
,
int
baudnum
);
/**
* Finaliza clasificacion. Finaliza iHaViMo.
*/
void
vision_cls_terminate
(
void
);
/**
* Retorna el preprocesamiento realizado sobre el resultado de la segmentacion de la imagen de HaViMo.
* Si no hay un nuevo frame para procesar se retorna NULL.
* force_frame fuerza la obtencion del frame.
*/
struct
blob
*
vision_cls_getNextFrame
(
unsigned
short
int
force_frame
);
/**
* Verifica si 2 blobs pueden ser combinados. Retorna la posicion del blob a, de acuerdo al blob b
* a blob para comparar con b
* b blob para comparar con a
* x_threshold umbral para la comparacion en el eje x
* y_threshold umbral para la comparacion en el eje y
* Retorna:
* 0 No pueden ser combinados
* 1 A arriba de B
* 2 A debajo B
* 3 A a la izquierda de B
* 4 A a la derecha de B
*/
int
vision_cla_canBlobsBeMerged
(
struct
blob
a
,
struct
blob
b
,
unsigned
int
x_threshold
,
unsigned
int
y_threshold
);
/**
* Mergear los blobs, a partir de un region_color especifico, usando como umbral GOAL_THRESHOLD_X y GOAL_THRESHOLD_Y
* blobs blobs a mergear
* region_color color que se debe mergear
* dont_process_blob array que define si no se debe procesar un blob
*/
void
vision_cls_mergeGoalBlobsByRegion
(
struct
blob
*
blobs
,
short
int
region_color
,
unsigned
short
int
*
dont_process_blob
);
#endif
visrob2/example/ejCAMVISCONF/config.c
0 → 100644
View file @
774bc15a
/*############################################################
# #
# Proyecto Futbol de Robots. - PAIE 2014 #
# http://www.fing.edu.uy/inco/proyectos/futbot13/ #
# #
############################################################*/
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include "confuse.h"
#include "config.h"
cfg_t
*
initCfg
(
const
char
*
fileConf
){
cfg_opt_t
objects_op
[]
=
{
CFG_INT
(
"id"
,
0
,
CFGF_NONE
),
CFG_INT_LIST
(
"hsiMin"
,
0
,
CFGF_NONE
),
CFG_INT_LIST
(
"hsiMax"
,
0
,
CFGF_NONE
),
CFG_END
()
};
cfg_opt_t
opts
[]
=
{
// CFG_INT("cant_objects", 0, CFGF_NONE), //cant objects allowed to detect
CFG_SEC
(
"region"
,
objects_op
,
CFGF_TITLE
|
CFGF_MULTI
),
//detailed objects params
// CFG_INT("rpi_cam", 0, CFGF_NONE), //using RPI camera connected via CSI --only for tests
// CFG_INT("rpi_cam", 0, CFGF_NONE), //using RPI camera connected via CSI --only for tests
CFG_END
()
};
cfg_t
*
cfg
=
cfg_init
(
opts
,
CFGF_NONE
);
switch
(
cfg_parse
(
cfg
,
fileConf
))
{
case
CFG_FILE_ERROR
:
printf
(
"warning: configuration file '%s' could not be read: %s
\n
"
,
fileConf
,
strerror
(
errno
));
printf
(
"continuing with default values...
\n\n
"
);
case
CFG_SUCCESS
:
break
;
case
CFG_PARSE_ERROR
:
return
0
;
}
return
cfg
;
}
visrob2/example/ejCAMVISCONF/config.h
0 → 100644
View file @
774bc15a
/*############################################################
# #
# Proyecto Futbol de Robots. - PAIE 2014 #
# http://www.fing.edu.uy/inco/proyectos/futbot13/ #
# #
############################################################*/
#ifndef I_CONFIG
#define I_CONFIG
#include "confuse.h"
cfg_t
*
initCfg
(
const
char
*
fileConf
);
#endif
visrob2/example/ejCAMVISCONF/confuse.h
0 → 100644
View file @
774bc15a
This diff is collapsed.
Click to expand it.
visrob2/example/ejCAMVISCONF/futbotVision.conf
0 → 100644
View file @
774bc15a
# regiones a detectar por el modulo vision -calibraciones
region
ball
{
id
=
0
hsiMin
={
11
,
207
,
81
}
hsiMax
={
19
,
255
,
202
}
}
region
field
{
id
=
1
hsiMin
={
25
,
7
,
125
}
hsiMax
={
33
,
31
,
32
}
}
region
my_goal
{
id
=
2
hsiMin
={
21
,
208
,
82
}
hsiMax
={
24
,
253
,
145
}
}
region
opp_goal
{
id
=
3
hsiMin
={
107
,
58
,
44
}
hsiMax
={
118
,
142
,
55
}
}
region
robot_body
{
id
=
4
hsiMin
={
0
,
0
,
19
}
hsiMax
={
0
,
0
,
22
}
}
region
cyan
{
id
=
5
hsiMin
={
0
,
0
,
0
}
hsiMax
={
0
,
0
,
0
}
}
region
magenta
{
id
=
6
hsiMin
={-
24
,
41
,
24
}
hsiMax
={
6
,
215
,
115
}
}
visrob2/example/ejCAMVISCONF/iVisionModule.h
0 → 100644
View file @
774bc15a
/*############################################################
# #
# Proyecto Futbol de Robots. - PAIE 2014 #
# http://www.fing.edu.uy/inco/proyectos/futbot13/ #
# #
############################################################*/
/**
* iVisionModule.h: Interfaz de capa de Interaccion con Camara.
* Realiza el pasaje de blobs detectado.
*/
#ifndef I_VISION_MODULE
#define I_VISION_MODULE
//Region index 0..15
#define INVALID_REGION 0
//Region color
#define UNKOWN_REGION 0
#define BALL_REGION 1
#define FIELD_REGION 2
#define MY_GOAL_REGION 3
#define OPP_GOAL_REGION 4
#define ROBOT_REGION 5
#define CYAN_REGION 6
#define MAGENTA_REGION 7
#define CANT_REGIONS 15
#define IMAGE_WIDTH 160 //px
#define IMAGE_HEIGHT 120 //px
#define DISTANCIA_FOCAL_HAVIMO 164//d(cm) * ancho(px) / ancho(cm)
#define DFH_FOR_PROPORTION 179
struct
blob
{
unsigned
int
region_index
;
unsigned
int
region_color
;
unsigned
int
number_of_pixels
;
unsigned
int
sum_of_x_coord_high
;
unsigned
int
sum_of_x_coord_low
;
unsigned
int
sum_of_y_coord_high
;
unsigned
int
sum_of_y_coord_low
;
unsigned
int
max_x
;
unsigned
int
min_x
;
unsigned
int
max_y
;
unsigned
int
min_y
;
};
/**
* Inicializa las estructuras que utiliza la interfaz.
*/
int
iVisionModule_initialize
(
int
ID
,
int
rate
);
/**
* Elimina las estructuras utilizadas por el modulo.
*/
int
iVisionModule_terminate
(
void
);
/**
* Obtiene el siguiente frame de la camara. En caso de que no este disponible se devuelve NULL
* Si el resultado es valido, antes de devolverlo se procesa.
*/
struct
blob
*
iVisionModule_getNextFrame
(
int
ID
);
/*---------------FUNCIONES AUXILIARES PARA MANEJO DE BLOB---------------*/
/**
* Retorna la comparacion de los arrays de blobs b1 y b2
* b1: array para comparar con b2
* b2: array para comparar con b1
*/
unsigned
int
blob_array_blob_equals
(
struct
blob
*
b1
,
struct
blob
*
b2
);
/**
* Compara 2 blobs
* b1: blob a comparar con b2
* b2: blob a comparar con b1
*/
unsigned
int
blob_equals
(
struct
blob
b1
,
struct
blob
b2
);
/**
* Imprime un conjunto de blobs en consola. Se debe estar conectado a través del puerto serial.
* blobs: array de blobs a imprimr
*/
void
iVisionModule_printBlobs
(
struct
blob
*
blobs
);
#endif
visrob2/example/ejCAMVISCONF/icvBlobs.c
0 → 100644
View file @
774bc15a
/*############################################################
# #
# Proyecto Futbol de Robots. - PAIE 2014 #
# http://www.fing.edu.uy/inco/proyectos/futbot13/ #
# #
############################################################*/
#include "iVisionModule.h"
#include "utilsBlobs.h"
#include <stdio.h>
#include <stdlib.h>
int
BLOB_LENGTH
=
0x10
;
//se leen 16 bytes
/**
* Retorna la comparacion de los arrays de blobs b1 y b2
* b1: array para comparar con b2
* b2: array para comparar con b1
*/
unsigned
int
blob_array_blob_equals
(
struct
blob
*
b1
,
struct
blob
*
b2
)
{
int
i
;