1 #include "linearClassifierModule.h"
2 #include <yarp/os/Stamp.h>
4 bool linearClassifierModule::configure(yarp::os::ResourceFinder &rf)
8 string moduleName = rf.check(
"name", Value(
"linearClassifier"),
"module name (string)").asString().c_str();
9 setName(moduleName.c_str());
12 handlerPortName =
"/";
13 handlerPortName += getName(rf.check(
"CommandPort",Value(
"/rpc"),
"Output image port (string)").asString().c_str());
17 if (!handlerPort.open(handlerPortName.c_str())) {
18 cout <<
": unable to open port " << handlerPortName << endl;
25 lCThread =
new linearClassifierThread(rf,&handlerPort);
34 bool linearClassifierModule::interruptModule()
43 bool linearClassifierModule::close()
53 bool linearClassifierModule::respond(
const Bottle& command, Bottle& reply)
57 reply.addString(
"nack");
61 if(command.get(0).asString()==
"save" && command.size()==2)
63 string obj=command.get(1).asString().c_str();
64 this->lCThread->prepareObjPath(obj);
65 reply.addString(
"ack");
69 if(command.get(0).asString()==
"stop")
71 this->lCThread->stopAll();
72 reply.addString(
"ack");
76 if(command.get(0).asString()==
"objList")
78 reply.addString(
"ack");
79 this->lCThread->getClassList(reply.addList());
83 if(command.get(0).asString()==
"changeName")
85 string old_name=command.get(1).asString().c_str();
86 string new_name=command.get(2).asString().c_str();
87 reply.addString(this->lCThread->changeName(old_name,new_name)?
"ack":
"nack");
91 if(command.get(0).asString()==
"train")
93 this->lCThread->trainClassifiers();
94 reply.addString(
"ack");
98 if(command.get(0).asString()==
"recognize")
100 bool ack=this->lCThread->startRecognition();
101 reply.addString(ack?
"ack":
"nack");
105 if(command.get(0).asString()==
"forget" && command.size()>1)
107 string className=command.get(1).asString().c_str();
109 this->lCThread->forgetAll();
111 this->lCThread->forgetClass(className,
true);
112 reply.addString(
"ack");
116 reply.addString(
"nack");
121 bool linearClassifierModule::updateModule()
127 double linearClassifierModule::getPeriod()