icub-client
AgentDetector.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 WYSIWYD Consortium, European Commission FP7 Project ICT-612139
3  * Authors: Stéphane Lallée
4  * email: stephane.lallee@gmail.com
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  * icub-client/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 <ctime>
19 #include <string>
20 #include <map>
21 
22 #include <yarp/os/RFModule.h>
23 #include <yarp/math/Math.h>
24 #include <kinectWrapper/kinectWrapper_client.h>
27 
28 using namespace std;
29 using namespace yarp::os;
30 using namespace yarp::sig;
31 using namespace yarp::math;
32 using namespace kinectWrapper;
33 using namespace icubclient;
34 
38 typedef enum {
42 
46 class AgentDetector: public RFModule
47 {
48 protected:
49  //Kinect Related
50  KinectWrapperClient client;
51  ImageOf<PixelRgb> rgb;
52  ImageOf<PixelMono16> depth;
53  ImageOf<PixelFloat> depthToDisplay;
54  ImageOf<PixelBgr> playersImage;
55  ImageOf<PixelBgr> skeletonImage;
56  IplImage* depthTmp;
57  IplImage* rgbTmp;
58 
59  yarp::os::BufferedPort<Bottle> outputSkeletonPort;
60  yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelFloat> > depthPort;
61  yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb> > imagePort;
62  yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelBgr> > playersPort;
63  yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelBgr> > skeletonPort;
64  yarp::os::BufferedPort<Bottle> agentLocOutPort;
65 
66  double period;
67  bool showImages;
68  string showMode;
70  Player joint;
71  deque<Player> joints;
72  Matrix players;
74 
75  //OPC/RFH related
77  Port rfh;
78  Port rpc;
79  bool isMounted;
80  bool isCalibrated;
81  Matrix kinect2icub;
82  Matrix icub2ir;
83 
84  int pointsCnt;
85  static clickType clicked;
86  static float clickX, clickY;
87 
88  //Agent Identity related
90  map<int, string> identities;
91  map<string, Vector> skeletonPatterns;
92  double dSince;
93 
94  unsigned long dTimingLastApparition;
96 
97  Mutex m;
98 
99  bool showImageParser(string &mode, string &submode);
100 
101 public:
102 
103  bool configure(ResourceFinder &rf);
104 
105  bool checkCalibration();
106 
107  bool close();
108 
109  bool respond(const Bottle& cmd, Bottle& reply);
110 
111  double getPeriod();
112 
113  bool updateModule();
114 
120  void setIdentity(Player p, string name);
121 
127  string getIdentity(Player p);
128 
134  Vector transform2IR(Vector v);
135 
141  Vector getSkeletonPattern(Player p);
142 
143  static void click_callback(int event, int x, int y, int flags, void* param)
144  {
145  (void) flags; // to prevent unused variable warning
146  (void) param; // to prevent unused variable warning
147 
148  switch (event)
149  {
150  case CV_EVENT_LBUTTONDOWN:
151  yInfo()<<"Got a left-click.";
152  AgentDetector::clickX=(float)x;
153  AgentDetector::clickY=(float)y;
155  break;
156  case CV_EVENT_RBUTTONDOWN:
157  yInfo()<<"Got a right-click.";
159  break;
160  }
161  }
162 };
163 
int pointsCnt
integer of number of points
Definition: AgentDetector.h:84
OPCClient * opc
OPC client object.
Definition: AgentDetector.h:76
deque< Player > joints
Definition: AgentDetector.h:71
ImageOf< PixelBgr > skeletonImage
skeleton imange in a Yarp format
Definition: AgentDetector.h:55
Agent * partner
human as an agent object
Definition: AgentDetector.h:89
static void click_callback(int event, int x, int y, int flags, void *param)
IplImage * depthTmp
Definition: AgentDetector.h:56
map< int, string > identities
Definition: AgentDetector.h:90
static float clickX
Definition: AgentDetector.h:86
static clickType clicked
clicked type of object: left, right or nothing
Definition: AgentDetector.h:85
STL namespace.
Port rfh
port to referenceFrameHandler
Definition: AgentDetector.h:77
static float clickY
float value of clicked coordinate in x and y axes
Definition: AgentDetector.h:86
yarp::os::BufferedPort< Bottle > agentLocOutPort
Output Yarp Buffered Port of Bottle contains agent location.
Definition: AgentDetector.h:64
bool isMounted
boolean value to check if the IR is mounted or not
Definition: AgentDetector.h:79
map< string, Vector > skeletonPatterns
properties of skeleton obtained from kinect
Definition: AgentDetector.h:91
Represent an agent.
Definition: agent.h:93
string partner_default_name
string value of default name of partner
Definition: AgentDetector.h:73
ImageOf< PixelBgr > playersImage
partner image in a Yarp format
Definition: AgentDetector.h:54
yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelBgr > > playersPort
Output Yarp Buffered Port of partner images.
Definition: AgentDetector.h:62
string showMode
string value of show mode of module: rgb, depth, skeleton, players
Definition: AgentDetector.h:68
yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelFloat > > depthPort
Output Yarp Buffered Port of images contains depth information.
Definition: AgentDetector.h:60
An OPC client using the datastructures defined within the icub-client library.
Definition: opcClient.h:35
Port rpc
rpc server port to receive requests
Definition: AgentDetector.h:78
ImageOf< PixelMono16 > depth
depth image in a Yarp format
Definition: AgentDetector.h:52
Matrix kinect2icub
conversion matrix from kinect frame to icub frame
Definition: AgentDetector.h:81
ImageOf< PixelRgb > rgb
Definition: AgentDetector.h:51
double dThresholdDisparition
timing maximal of non-reconnaissance of a agent, after thath we consider the agent as absent ...
Definition: AgentDetector.h:95
double dSince
double value of timers
Definition: AgentDetector.h:92
KinectWrapperClient client
kinect wrapper client object
Definition: AgentDetector.h:50
yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelRgb > > imagePort
Output Yarp Buffered Port of images contains images.
Definition: AgentDetector.h:61
yarp::os::BufferedPort< Bottle > outputSkeletonPort
Output Yarp Buffered Port of Bottle contains skeleton properties.
Definition: AgentDetector.h:59
yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelBgr > > skeletonPort
Output Yarp Buffered Port of skeleton images.
Definition: AgentDetector.h:63
bool handleMultiplePlayers
boolean value for multiple players or not, if not, obtain only the closest player ...
Definition: AgentDetector.h:69
unsigned long dTimingLastApparition
time struct of the last appartition of an agent
Definition: AgentDetector.h:94
ImageOf< PixelFloat > depthToDisplay
depth image to display in a Yarp format
Definition: AgentDetector.h:53
clickType
Definition: AgentDetector.h:38
bool isCalibrated
boolean value to check if the kinect is calibrated or not
Definition: AgentDetector.h:80
IplImage * rgbTmp
Definition: AgentDetector.h:57