5 #include <yarp/os/all.h>
6 #include <yarp/sig/all.h>
7 #include <yarp/math/Math.h>
12 #include "win_dirent.h"
17 #define STATE_DONOTHING 0
18 #define STATE_SAVING 1
19 #define STATE_RECOGNIZING 2
22 using namespace yarp::os;
23 using namespace yarp::sig;
24 using namespace yarp::math;
27 class linearClassifierThread :
public Thread
31 string outputPortName;
32 string outputScorePortName;
37 BufferedPort<Bottle> featuresPort;
38 BufferedPort<Bottle> outputPort;
43 vector<pair<string,vector<string> > > knownObjects;
44 vector<SVMLinear> linearClassifiers;
45 vector<int> datasetSizes;
46 vector<vector<vector<double> > > Features;
47 vector<vector<double > > bufferScores;
48 vector<vector<int > > countBuffer;
55 void checkKnownObjects();
56 int getdir(
const string &dir, vector<string> &files);
58 bool trainClassifiersHelper();
59 bool forgetClassHelper(
const string &className,
const bool retrain);
63 linearClassifierThread(yarp::os::ResourceFinder &rf,Port* commPort);
64 void prepareObjPath(
const string &objName);
69 void createFullPath(
const char * path);
72 bool trainClassifiers();
73 bool startRecognition();
74 bool forgetClass(
const string &className,
const bool retrain);
76 bool getClassList(Bottle &b);
77 bool changeName(
const string &old_name,
const string &new_name);