icub-client
AgentDetector.cpp
Go to the documentation of this file.
1 
2 #include <vector>
3 #include "AgentDetector.h"
4 
6 float AgentDetector::clickX=0.0F;
7 float AgentDetector::clickY=0.0F;
8 
9 
10 bool AgentDetector::showImageParser(string &mode, string &submode)
11 {
12  submode=mode;
13  size_t found=mode.find_first_of('+');
14  if ((found>0) && (found!=string::npos))
15  {
16  submode=mode.substr(0,found);
17  if (found+1<mode.length())
18  mode=mode.substr(found+1,mode.length()-found);
19  else
20  mode.clear();
21  }
22  else
23  mode.clear();
24 
25  return !submode.empty();
26 }
27 
28 bool AgentDetector::configure(ResourceFinder &rf)
29 {
30  period = rf.check("period",Value(0.03)).asDouble();
31  int verbosity=rf.check("verbosity",Value(0)).asInt();
32  string name=rf.check("name",Value("agentDetector")).asString().c_str();
33  handleMultiplePlayers = rf.check("multiplePlayers");
34  isMounted = !rf.check("isFixed");
35  string show=rf.check("showImages",Value("false")).asString().c_str();
36  showMode=rf.check("showMode",Value("rgb+depth+skeleton+players")).asString().c_str();
37  dThresholdDisparition = rf.check("dThresholdDisparition",Value("3.0")).asDouble();
38 
39  // initialise timing in case of misrecognition
40  dTimingLastApparition = clock();
41 
42  //Open the OPC Client
43  partner_default_name=rf.check("partner_default_name",Value("partner")).asString().c_str();
44 
45  string opcName=rf.check("opc",Value("OPC")).asString().c_str();
46  opc = new OPCClient(name);
47  dSince = 0.0;
48  while (!opc->connect(opcName))
49  {
50  yInfo()<<"Waiting connection to OPC...";
51  Time::delay(1.0);
52  }
53  opc->checkout();
54 
55  list<shared_ptr<Entity>> entityList = opc->EntitiesCacheCopy();
56  for(auto e : entityList) {
57  if(e->entity_type() == ICUBCLIENT_OPC_ENTITY_AGENT && e->name() != "icub") {
58  partner_default_name = e->name();
59  }
60  }
61 
63  partner->m_present = 0.0;
64  opc->commit(partner);
65 
66  //Retrieve the calibration matrix from RFH
67  string rfhName=rf.check("rfh",Value("referenceFrameHandler")).asString().c_str();
68  rfh.open("/"+name+"/rfh:o");
69 
70  string rfhRemote = "/"+rfhName+"/rpc";
71 
72  while (!Network::connect(rfh.getName(), rfhRemote.c_str()))
73  {
74  yInfo()<<"Waiting connection to RFH...";
75  Time::delay(1.0);
76  }
77 
78  isCalibrated=false;
79  if(!checkCalibration())
80  yWarning() << " ========================= KINECT NEEDS TO BE CALIBRATED ============================" ;
81 
82  string clientName = name + "/kinect";
83 
84  outputSkeletonPort.open(("/"+name+"/skeleton:o").c_str());
85  depthPort.open(("/"+clientName+"/depthPort:o").c_str());
86  imagePort.open(("/"+clientName+"/imagePort:o").c_str());
87  playersPort.open(("/"+clientName+"/playersPort:o").c_str());
88  skeletonPort.open(("/"+clientName+"/skeletonPort:o").c_str());
89  agentLocOutPort.open(("/"+clientName+"/agentLoc:o").c_str());
90 
91  Property options;
92  options.put("carrier","tcp");
93  options.put("remote","kinectServer");
94  options.put("local",clientName.c_str());
95  options.put("verbosity",verbosity);
96 
97  if (!client.open(options))
98  return false;
99 
100  Property opt;
101  client.getInfo(opt);
102 
103  showImages=(show=="true")?true:false;
104  int xPos = rf.check("x",Value(10)).asInt();
105  int yPos = rf.check("y",Value(10)).asInt();
106 
107  int img_width=opt.find("img_width").asInt();
108  int img_height=opt.find("img_height").asInt();
109  int depth_width=opt.find("depth_width").asInt();
110  int depth_height=opt.find("depth_height").asInt();
111 
112  rgb.resize(img_width, img_height);
113  depth.resize(depth_width,depth_height);
114  depthToDisplay.resize(depth_width,depth_height);
115  playersImage.resize(depth_width,depth_height);
116  skeletonImage.resize(depth_width,depth_height);
117 
118  depthTmp=cvCreateImage(cvSize(depth_width,depth_height),IPL_DEPTH_32F,1);
119  rgbTmp=cvCreateImage(cvSize(img_width,img_height),IPL_DEPTH_8U,3);
120 
121  if (showImages)
122  {
123  vector<bool> alreadyOpen(4,false);
124  string mode=showMode;
125  string submode;
126  while (!mode.empty())
127  {
128  if (showImageParser(mode,submode))
129  {
130  if (submode=="rgb")
131  {
132  if (!alreadyOpen[0])
133  {
134  int x_rgb=rf.check("x-rgb",Value(xPos)).asInt();
135  int y_rgb=rf.check("y-rgb",Value(yPos)).asInt();
136  yInfo("\"rgb\" window selected in (%d,%d)",x_rgb,y_rgb);
137 
138  cvNamedWindow("rgb",CV_WINDOW_AUTOSIZE);
139  cvMoveWindow("rgb",x_rgb,y_rgb);
140  alreadyOpen[0]=true;
141  }
142  else
143  yWarning("\"rgb\" window already open");
144  }
145  else if (submode=="depth")
146  {
147  if (!alreadyOpen[1])
148  {
149  int x_depth=rf.check("x-depth",Value(xPos+300)).asInt();
150  int y_depth=rf.check("y-depth",Value(yPos)).asInt();
151  yInfo("\"depth\" window selected in (%d,%d)",x_depth,y_depth);
152 
153  cvNamedWindow("depth",CV_WINDOW_AUTOSIZE);
154  cvMoveWindow("depth",x_depth,y_depth);
155  cvSetMouseCallback("depth",AgentDetector::click_callback,
156  (void*)depthToDisplay.getIplImage());
157  alreadyOpen[1]=true;
158  }
159  else
160  yWarning("\"depth\" window already open");
161  }
162  else if (submode=="skeleton")
163  {
164  if (!alreadyOpen[2])
165  {
166  int x_skeleton=rf.check("x-skeleton",Value(xPos)).asInt();
167  int y_skeleton=rf.check("y-skeleton",Value(yPos+300)).asInt();
168  yInfo("\"skeleton\" window selected in (%d,%d)",x_skeleton,y_skeleton);
169 
170  cvNamedWindow("skeleton",CV_WINDOW_AUTOSIZE);
171  cvMoveWindow("skeleton",x_skeleton,y_skeleton);
172  alreadyOpen[2]=true;
173  }
174  else
175  yWarning("\"skeleton\" window already open");
176  }
177  else if (submode=="players")
178  {
179  if (!alreadyOpen[3])
180  {
181  int x_players=rf.check("x-players",Value(xPos+300)).asInt();
182  int y_players=rf.check("y-players",Value(yPos+300)).asInt();
183  yInfo("\"players\" window selected in (%d,%d)",x_players,y_players);
184 
185  cvNamedWindow("players",CV_WINDOW_AUTOSIZE);
186  cvMoveWindow("players",x_players,y_players);
187  alreadyOpen[3]=true;
188  }
189  else
190  yWarning("\"players\" window already open");
191  }
192  else
193  yError("unrecognized show mode!");
194  }
195  }
196  }
197 
198  rpc.open("/"+name+"/rpc");
199  attach(rpc);
200 
201  pointsCnt=0;
202  return true;
203 }
204 
206 {
207  if (isCalibrated)
208  return true;
209 
210  if (rfh.getOutputCount()>0)
211  {
212  Bottle bCmd,reply;
213  bCmd.addString("mat");
214  bCmd.addString("kinect");
215  bCmd.addString("icub");
216  rfh.write(bCmd,reply);
217 
218  if (reply.get(0).asString()!="nack")
219  {
220  if (Bottle *bMat=reply.get(1).asList())
221  {
222  kinect2icub.resize(4,4);
223  for (int i=0; i<4; i++)
224  for (int j=0; j<4; j++)
225  kinect2icub(i,j)=bMat->get(4*i+j).asDouble();
226  return isCalibrated=true;
227  }
228  }
229  }
230 
231  return false;
232 }
233 
235 {
236  depthPort.interrupt();
237  depthPort.close();
238  imagePort.interrupt();
239  imagePort.close();
240  playersPort.interrupt();
241  playersPort.close();
242  skeletonPort.interrupt();
243  skeletonPort.close();
244  outputSkeletonPort.interrupt();
245  outputSkeletonPort.close();
246  agentLocOutPort.interrupt();
247  agentLocOutPort.close();
248  client.close();
249  cvReleaseImage(&depthTmp);
250  cvReleaseImage(&rgbTmp);
251  opc->close();
252  rfh.close();
253 
254  delete opc;
255 
256  return true;
257 }
258 
259 bool AgentDetector::respond(const Bottle& cmd, Bottle& reply)
260 {
261  if (cmd.get(0).asString() == "change_partner_name" ) {
262  if(cmd.get(1).isString()) {
263  reply.addString("ack");
264  partner_default_name=cmd.get(1).asString();
266  } else {
267  reply.addString("nack");
268  }
269  }
270  else if (cmd.get(0).asString() == "pause" ) {
271  m.lock();
272  reply.addString("ack");
273  }
274  else if (cmd.get(0).asString() == "resume" ) {
275  m.unlock();
276  reply.addString("ack");
277  }
278  else
279  {
280  reply.addString("nack");
281  }
282  return true;
283 }
284 
286 {
287  return period;
288 }
289 
291 {
292  LockGuard lg(m);
293 
294  bool isRefreshed = client.getDepthAndPlayers(depth,players);
295  client.getRgb(rgb);
296 
297  bool tracked;
298 
300  tracked=client.getJoints(joints);
301  else
302  tracked=client.getJoints(joint, ICUBCLIENT_KINECT_CLOSEST_PLAYER);
303 
304  if (tracked)
305  {
307  client.getSkeletonImage(joints,skeletonImage);
308  else
309  {
310  client.getSkeletonImage(joint,skeletonImage);
311  joints.clear();
312  joints.push_back(joint);
313  }
314  }
315 
316  client.getPlayersImage(players,playersImage);
317  client.getDepthImage(depth,depthToDisplay);
318 
319  if (depthPort.getOutputCount()>0)
320  {
321  depthPort.prepare()=depthToDisplay;
322  depthPort.write();
323  }
324 
325  if (imagePort.getOutputCount()>0)
326  {
327  imagePort.prepare()=rgb;
328  imagePort.write();
329  }
330 
331  if (playersPort.getOutputCount()>0)
332  {
333  playersPort.prepare()=playersImage;
334  playersPort.write();
335  }
336 
337  if (skeletonPort.getOutputCount()>0)
338  {
339  skeletonPort.prepare()=skeletonImage;
340  skeletonPort.write();
341  }
342 
343  if (showImages)
344  {
345  cvConvertScale((IplImage*)depthToDisplay.getIplImage(),depthTmp,1.0/255);
346  cvCvtColor((IplImage*)rgb.getIplImage(),rgbTmp,CV_BGR2RGB);
347 
348  string mode=showMode;
349  string submode;
350  while (!mode.empty())
351  {
352  if (showImageParser(mode,submode))
353  {
354  if (submode=="rgb")
355  cvShowImage("rgb",rgbTmp);
356  else if (submode=="depth")
357  cvShowImage("depth",depthTmp);
358  else if (submode=="skeleton")
359  cvShowImage("skeleton",(IplImage*)skeletonImage.getIplImage());
360  else if (submode=="players")
361  cvShowImage("players",(IplImage*)playersImage.getIplImage());
362  else
363  yError("unrecognized show mode!");
364  }
365  }
366 
367  cvWaitKey(1);
368  }
369 
370  //Send the players information to the OPC
371  //Allow click calibration
372  if (!checkCalibration())
373  {
375  {
377 
378  //Get the clicked point coordinate in Kinect space
379  Vector clickedPoint(3);
380  yInfo("Processing a click on (%f %f) -->",AgentDetector::clickX, AgentDetector::clickY);
381  client.get3DPoint((int)AgentDetector::clickX,(int)AgentDetector::clickY,clickedPoint);
382  yInfo()<<clickedPoint.toString(3,3);
383 
384  Bottle bCond;
385  Bottle bObject;
386 
387  bObject.addString(ICUBCLIENT_OPC_ENTITY_TAG);
388  bObject.addString("==");
389  bObject.addString(ICUBCLIENT_OPC_ENTITY_OBJECT);
390 
391  Bottle bPresent;
392  bPresent.addString(ICUBCLIENT_OPC_OBJECT_PRESENT_TAG);
393  bPresent.addString("==");
394  bPresent.addDouble(1.0);
395 
396  bCond.addList()=bObject;
397  bCond.addString("&&");
398  bCond.addList()=bPresent;
399 
400  opc->checkout();
401  opc->isVerbose=true;
402  list<Entity*> presentObjects=opc->Entities(bCond);
403  opc->isVerbose=false;
404 
405  Object *o=nullptr;
406  if (presentObjects.size()==1) {
407  o=dynamic_cast<Object*>(presentObjects.front());
408  } else {
409  for(auto& presentObject : presentObjects) {
410  if(presentObject->name() == "target") {
411  o=dynamic_cast<Object*>(presentObject);
412  break;
413  }
414  }
415  }
416  if(o) {
417  Bottle botRPH, botRPHRep;
418  botRPH.addString("add");
419  botRPH.addString("kinect");
420  Bottle &cooKinect=botRPH.addList();
421  cooKinect.addDouble(clickedPoint[0]);
422  cooKinect.addDouble(clickedPoint[1]);
423  cooKinect.addDouble(clickedPoint[2]);
424 
425  Bottle &cooiCub=botRPH.addList();
426  cooiCub.addDouble(o->m_ego_position[0]);
427  cooiCub.addDouble(o->m_ego_position[1]);
428  cooiCub.addDouble(o->m_ego_position[2]);
429  rfh.write(botRPH,botRPHRep);
430  yInfo("Sent to RFH: %s", botRPH.toString().c_str());
431  yInfo("Got from RFH: %s", botRPHRep.toString().c_str());
432 
433  pointsCnt++;
434  } else {
435  yWarning("There should be 1 and only 1 object on the table");
436  yWarning("If there is more than one object, the object you want");
437  yWarning("to calibrate must be called \"target\"");
438  }
439  }
441  {
443  if (pointsCnt>=3)
444  {
445  Bottle calibBottle,calibReply;
446  calibBottle.addString("cal");
447  calibBottle.addString("kinect");
448  rfh.write(calibBottle,calibReply);
449  yInfo("Calibrated: %s!", calibReply.toString().c_str());
450 
451  calibBottle.clear();
452  calibBottle.addString("save");
453  rfh.write(calibBottle,calibReply);
454  yInfo("Saved to file: %s!", calibReply.toString().c_str());
456  }
457  else
458  yWarning("Unable to calibrate with less than 3 points pairs collected");
459  }
460  }
461 
462  if (isRefreshed)
463  {
464  if (tracked)
465  {
466  //Go through all skeletons
467  for(deque<Player>::iterator p=joints.begin(); p!=joints.end(); p++)
468  {
469  //check if this skeletton is really tracked
470  bool reallyTracked = false;
471  for(map<string,Joint>::iterator jnt = p->skeleton.begin() ; jnt != p->skeleton.end() ; jnt++)
472  {
473  if (jnt->second.x != 0 && jnt->second.y != 0 && jnt->second.z != 0)
474  {
475  reallyTracked = true; break;
476  }
477  }
478  if (reallyTracked)
479  {
480  dSince = (clock() - dTimingLastApparition) / (double) CLOCKS_PER_SEC;
481  //yInfo() << " is REALLY tracked";
482  string playerName = partner_default_name;
483 
484  //If the skeleton is tracked we dont identify
485  if (identities.find(p->ID) != identities.end())
486  {
487  playerName = identities[p->ID];
488  }
489  else
490  {
491  playerName = getIdentity(*p);
492  }
493 
494  //We interact with OPC only if the calibration is done
495  if (isCalibrated)
496  {
497  //main bottle to be streamed with loc of all agent body part
498  Bottle& bAgentLoc = agentLocOutPort.prepare();
499  bAgentLoc.clear();
500 
501  //Retrieve this player in OPC or create if does not exist
502  opc->checkout();
504  partner->m_present = 1.0;
505 
506  // reset the timing.
507  dTimingLastApparition = clock();
508 
509  if (identities.find(p->ID) == identities.end())
510  {
511  yInfo("Assigning name %s to skeleton %i", playerName.c_str(), p->ID);
512 
513  Agent* specificAgent = opc->addOrRetrieveEntity<Agent>(playerName);
514  if(specificAgent == nullptr) {
515  yError() << playerName << " is not in the OPC";
516  } else {
517  identities[p->ID] = specificAgent->name();
518  specificAgent->m_present = 1.0;
519  yInfo() << " specific agent is commited";
520  opc->commit(specificAgent);
521  yInfo() << " specific agent is commited done";
522  }
523  }
524 
525  yarp::os::Bottle &skeleton = outputSkeletonPort.prepare();
526  skeleton.clear();
527  //Convert the skeleton into ICUBCLIENTHelpers body. We loose orientation in the process...
528  for(map<string,Joint>::iterator jnt = p->skeleton.begin() ; jnt != p->skeleton.end() ; jnt++)
529  {
530  Bottle bBodyPartLoc;
531 
532  Vector kPosition(4);
533  kPosition[0] = jnt->second.x;
534  kPosition[1] = jnt->second.y;
535  kPosition[2] = jnt->second.z;
536  kPosition[3] = 1;
537  Vector icubPos = kinect2icub * kPosition;
538  Vector irPos = icubPos.subVector(0,2);
539 
540  if (isMounted)
541  {
542  irPos = transform2IR(irPos);
543  Bottle jntBtl;
544  jntBtl.clear();
545  jntBtl.addString(jnt->first);
546  jntBtl.addDouble(jnt->second.x);
547  jntBtl.addDouble(jnt->second.y);
548  jntBtl.addDouble(jnt->second.z);
549  skeleton.addList() = jntBtl;
550  }
551 
552  if (jnt->first == ICUBCLIENT_OPC_BODY_PART_TYPE_HEAD)
553  {
554  partner->m_ego_position = irPos;
555  }
556  partner->m_body.m_parts[jnt->first] = irPos;
557 
558  bBodyPartLoc.addString(jnt->first);
559  bBodyPartLoc.addString(irPos.toString());
560 
561  bAgentLoc.addList() = bBodyPartLoc;
562  }
563 
564  agentLocOutPort.write();
565 
566  opc->commit(partner);
567  outputSkeletonPort.write();
568  }
569  }
570  }
571  }
572  else
573  {
575  {
576  opc->checkout();
578  partner->m_present = 0.0;
579  opc->commit(partner);
580  }
581  }
582  }
583  return true;
584 }
585 
586 double distanceVector(Joint j1, Joint j2)
587 {
588  return sqrt(pow((j1.x - j2.x),2.0) + pow((j1.y - j2.y),2.0) + pow((j1.z - j2.z),2.0));
589 }
590 
592 {
593  //Create the skeleton pattern
594  Vector pattern(5);
595 
601 
602  return pattern;
603 }
604 
605 
607 {
608  //If this tracked ID has already been identified we don't try again
609  if (identities.find(p.ID) != identities.end() )
610  {
611  return identities[p.ID];
612  }
613 
614  if (skeletonPatterns.size()>0)
615  {
616  double bestVal = DBL_MAX;
617  string bestName = partner_default_name;
618 
619  Vector currentPattern = getSkeletonPattern(p);
620  for(map<string, Vector>::iterator patternIt = skeletonPatterns.begin(); patternIt != skeletonPatterns.end();patternIt++)
621  {
622  double distance = 0;
623  for(size_t i=0; i<currentPattern.size();i++)
624  {
625  distance += pow( patternIt->second[i] - currentPattern[i], 2.0);
626  }
627  distance = sqrt(distance);
628 
629  if (distance < bestVal)
630  {
631  bestVal = distance;
632  bestName = patternIt->first;
633  }
634  }
635  return bestName;
636  }
637  else
638  {
639  return partner_default_name;
640  }
641 }
642 
644 {
645  Agent* icub = opc->addOrRetrieveEntity<Agent>("icub");
646  Vector Xs = icub->m_ego_position;
647  double phi = icub->m_ego_orientation[2] * M_PI / 180.0;
648 
649  Matrix H(4,4);
650  H(0,0) = cos(phi); H(0,1) = -sin(phi); H(0,2) = 0.0; H(0,3) = Xs[0];
651  H(1,0) = sin(phi); H(1,1) = cos(phi); H(1,2) = 0.0; H(1,3) = Xs[1];
652  H(2,0) = 0.0; H(2,1) = 0.0; H(2,2) = 1.0; H(2,3) = 0.0;
653  H(3,0) = 0.0; H(3,1) = 0.0; H(3,2) = 0.0; H(3,3) = 1.0;
654 
655  Vector vIR = v;
656  vIR.push_back(1.0);
657  vIR = H * vIR;
658  return vIR;
659 }
#define ICUBCLIENT_KINECT_CLOSEST_PLAYER
Definition: tags.h:144
int pointsCnt
integer of number of points
Definition: AgentDetector.h:84
#define ICUBCLIENT_OPC_BODY_PART_TYPE_ELBOW_L
Definition: tags.h:83
#define ICUBCLIENT_OPC_BODY_PART_TYPE_SHOULDER_L
Definition: tags.h:86
bool respond(const Bottle &cmd, Bottle &reply)
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
#define ICUBCLIENT_OPC_BODY_PART_TYPE_SHOULDER_R
Definition: tags.h:87
yarp::sig::VectorOf< double > m_ego_orientation
Orientation of the Object, in the initial ego-centered reference frame of the agent mainting the OPC ...
Definition: object.h:51
void close()
Close the client ports.
Definition: opcClient.cpp:69
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)
double m_present
Is the object present in the scene A value of 1.0 means that the object currently is in the scene A v...
Definition: object.h:69
IplImage * depthTmp
Definition: AgentDetector.h:56
void commit()
Commit all the entities & relations stored locally, erasing the server copies.
Definition: opcClient.cpp:835
#define ICUBCLIENT_OPC_BODY_PART_TYPE_HEAD
Definition: tags.h:78
map< int, string > identities
Definition: AgentDetector.h:90
static float clickX
Definition: AgentDetector.h:86
T * addOrRetrieveEntity(const std::string &name)
Obtains an entity with the given name.
Definition: opcClient.h:119
static clickType clicked
clicked type of object: left, right or nothing
Definition: AgentDetector.h:85
Port rfh
port to referenceFrameHandler
Definition: AgentDetector.h:77
bool connect(const std::string &opcName)
Try to connect the client to an OPC server.
Definition: opcClient.h:157
Represent any physical entity (including objects and agents) that can be stored within the OPC...
Definition: object.h:35
yarp::sig::VectorOf< double > m_ego_position
Position of the Object, in the initial ego-centered reference frame of the agent mainting the OPC (in...
Definition: object.h:46
static float clickY
float value of clicked coordinate in x and y axes
Definition: AgentDetector.h:86
string getIdentity(Player p)
getIdentity Obtain identity of partner
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
#define ICUBCLIENT_OPC_BODY_PART_TYPE_SHOULDER_C
Definition: tags.h:85
map< string, Vector > skeletonPatterns
properties of skeleton obtained from kinect
Definition: AgentDetector.h:91
bool configure(ResourceFinder &rf)
Represent an agent.
Definition: agent.h:93
string partner_default_name
string value of default name of partner
Definition: AgentDetector.h:73
Vector getSkeletonPattern(Player p)
getSkeletonPattern Obtain some properties of partner skeleton, such as eblow, shoulder, head position and size
ImageOf< PixelBgr > playersImage
partner image in a Yarp format
Definition: AgentDetector.h:54
bool showImageParser(string &mode, string &submode)
yarp::os::BufferedPort< yarp::sig::ImageOf< yarp::sig::PixelBgr > > playersPort
Output Yarp Buffered Port of partner images.
Definition: AgentDetector.h:62
std::list< std::shared_ptr< Entity > > EntitiesCacheCopy() const
Getter of the list of the copies of the entities stored locally.
Definition: opcClient.cpp:917
string showMode
string value of show mode of module: rgb, depth, skeleton, players
Definition: AgentDetector.h:68
double distanceVector(Joint j1, Joint j2)
#define ICUBCLIENT_OPC_ENTITY_TAG
Definition: tags.h:37
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
#define ICUBCLIENT_OPC_OBJECT_PRESENT_TAG
Definition: tags.h:45
Matrix kinect2icub
conversion matrix from kinect frame to icub frame
Definition: AgentDetector.h:81
double getPeriod()
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
std::list< Entity * > Entities(const yarp::os::Bottle &condition)
Getter of the list of entities of matching a complex condition (e.g "(entity "==" agent) "&&" (isPres...
Definition: opcClient.cpp:865
Vector transform2IR(Vector v)
transform2IR Transform a position to IR reference frame
double dSince
double value of timers
Definition: AgentDetector.h:92
#define ICUBCLIENT_OPC_ENTITY_OBJECT
Definition: tags.h:38
void checkout(bool updateCache=true)
Poll the OPC for all entities and relations and store them locally.
Definition: opcClient.cpp:754
#define ICUBCLIENT_OPC_BODY_PART_TYPE_SPINE
Definition: tags.h:88
KinectWrapperClient client
kinect wrapper client object
Definition: AgentDetector.h:50
bool checkCalibration()
#define ICUBCLIENT_OPC_ENTITY_AGENT
Definition: tags.h:40
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
std::map< std::string, yarp::sig::VectorOf< double > > m_parts
Definition: agent.h:35
IplImage * rgbTmp
Definition: AgentDetector.h:57