iol
classifier.h
1 /*
2  * Copyright (C) 2013 iCub Facility - Istituto Italiano di Tecnologia
3  * Author: Sean Ryan Fanello
4  * email: sean.fanello@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 #include <mutex>
19 #include <iostream>
20 #include <string>
21 #include <algorithm>
22 
23 #include <yarp/os/all.h>
24 #include <yarp/sig/all.h>
25 
26 using namespace std;
27 using namespace yarp::os;
28 using namespace yarp::sig;
29 
30 
31 class Classifier : public RFModule
32 {
33  mutex mtx;
34  Port scoresInput;
35  Port featureInput;
36  Port featureOutput;
37  Port imgOutput;
38 
39  RpcServer rpcPort;
40  RpcClient rpcClassifier;
41  RpcClient opcPort;
42 
43  BufferedPort<ImageOf<PixelRgb> > imgInput;
44  BufferedPort<ImageOf<PixelRgb> > imgSIFTInput;
45  BufferedPort<ImageOf<PixelRgb> > imgSIFTOutput;
46 
47  bool sync;
48  bool doTrain;
49  bool burst;
50 
51  vector<Bottle> trainingFeature;
52  vector<Bottle> negativeFeature;
53  string currObject;
54 
55  bool train(Bottle *locations, Bottle &reply);
56  void classify(Bottle *blobs, Bottle &reply);
57  bool getOPCList(Bottle &names);
58  bool updateObjDatabase();
59 
60 public:
61  bool configure(ResourceFinder &rf);
62  bool interruptModule();
63  bool close();
64  bool respond(const Bottle& command, Bottle& reply);
65  double getPeriod();
66  bool updateModule();
67 };