iol
src
iolStateMachineHandler
include
classifierHandling.h
1
/*
2
* Copyright (C) 2011 Department of Robotics Brain and Cognitive Sciences - Istituto Italiano di Tecnologia
3
* Author: Ugo Pattacini
4
* email: ugo.pattacini@iit.it
5
* Permission is granted to copy, distribute, and/or modify this program
6
* under the terms of the GNU General Public License, version 2 or any
7
* later version published by the Free Software Foundation.
8
*
9
* A copy of the license can be found at
10
* http://www.robotcub.org/icub/license/gpl.txt
11
*
12
* This program is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
* Public License for more details
16
*/
17
18
#ifndef __CLASSIFIERHANDLING_H__
19
#define __CLASSIFIERHANDLING_H__
20
21
#include <string>
22
#include <deque>
23
#include <map>
24
25
#include <yarp/os/Bottle.h>
26
27
#define OBJECT_UNKNOWN "-"
28
29
using namespace
std;
30
using namespace
yarp::os;
31
32
33
/**********************************************************/
34
class
Classifier
35
{
36
protected
:
37
string
name;
38
double
threshold;
39
double
newScore;
40
41
struct
Score
42
{
43
bool
isPositive;
44
double
score;
45
};
46
47
deque<Score> window;
48
size_t
winLen;
49
50
void
init(
const
double
thres=0.5);
51
void
push(
const
Score &s);
52
void
push(
const
bool
isPositive);
53
void
declare(
const
bool
isPositive);
54
double
update();
55
56
public
:
57
Classifier(
const
double
thres=0.5);
58
Classifier(
const
Classifier &classifier);
59
Classifier(
const
string
&name,
const
double
thres=0.5);
60
Classifier(
const
Bottle &options);
61
string
getName()
const
{
return
name; }
62
bool
isThis(
const
double
val)
const
;
63
void
prepare(
const
double
newScore);
64
void
negative();
65
void
positive();
66
void
fromBottle(
const
Bottle &options);
67
Bottle toBottle();
68
};
69
70
71
/**********************************************************/
72
class
ClassifiersDataBase :
public
map<string,Classifier*>
73
{
74
public
:
75
~ClassifiersDataBase();
76
void
clear();
77
void
erase(iterator it);
78
int
processScores(Classifier *pClassifier,
const
Bottle &scores);
79
string
findName(
const
Bottle &scores,
const
string
&tag,
double
*score=
nullptr
);
80
};
81
82
#endif
83
Generated by
1.9.1