bool PasarModule::updateModule() { opc->update(); list<Entity*> entities = opc->EntitiesCache(); presentObjects.clear(); presentLastSpeed = presentCurrentSpeed; presentCurrentSpeed.clear(); for(list<Entity*>::iterator it=entities.begin(); it !=entities.end(); it++) { if ((*it)->name() != "icub") { //!!! ONLY RT_OBJECT and AGENTS ARE TRACKED !!! if ( ( (*it)->isType(EFAA_OPC_ENTITY_OBJECT) )) { if ((*it)->isType(EFAA_OPC_ENTITY_RTOBJECT)) { RTObject * rto = opc->addRTObject((*it)->name()); presentObjects[ (*it)->name() ].o.fromBottle( rto->asBottle() ); presentObjects[ (*it)->name() ].o.m_saliency = rto->m_saliency; presentObjects[ (*it)->name() ].speed = 0.0; presentObjects[ (*it)->name() ].acceleration = 0.0; presentObjects[ (*it)->name() ].restingSteps = 0; } if ((*it)->isType(EFAA_OPC_ENTITY_AGENT)) { Agent *ag = opc->addAgent((*it)->name()); presentObjects[ (*it)->name() ].o.fromBottle( ag->asBottle() ); presentObjects[ (*it)->name() ].o.m_saliency = ag->m_saliency; presentObjects[ (*it)->name() ].speed = 0.0; presentObjects[ (*it)->name() ].acceleration = 0.0; presentObjects[ (*it)->name() ].restingSteps = 0; }/* presentObjects[ (*it)->name() ].o.fromBottle( (*it)->asBottle() ); presentObjects[ (*it)->name() ].o.m_saliency = 0.0; presentObjects[ (*it)->name() ].speed = 0.0; presentObjects[ (*it)->name() ].acceleration = 0.0; presentObjects[ (*it)->name() ].restingSteps = 0;*/ } } //if (presentObjects[ (*it)->name() ].o.m_saliency > 0) // cout<<" salience : " << (*it)->name() << " " << presentObjects[ (*it)->name() ].o.m_saliency << endl; } if (presentObjectsLastStep.size() > 0) { //Retrieve the bottom-up saliency (vision based) and attribute it to objects //saliencyBottomUp(); //Compute top down saliency (concept based) saliencyTopDown(); //Normalize //saliencyNormalize(); //Inhinbition of return // if(trackedObject!= "") // presentObjects[trackedObject].o.m_saliency = max(0.0, presentObjects[trackedObject].o.m_saliency - pTopDownInhibitionReturn); //Leaky integrate saliencyLeakyIntegration(); //Get the most salient object and track it map< string, ObjectModel >::iterator mostSalientObject = presentObjects.begin(); for(map< string, ObjectModel >::iterator it=presentObjects.begin(); it!=presentObjects.end();it++) { // cout<<"Saliency ("<<it->second.o.name()<<") = "<<it->second.o.m_saliency<<endl; if (it->second.o.m_saliency > mostSalientObject->second.o.m_saliency) mostSalientObject = it; } trackedObject = mostSalientObject->first; if (presentObjects[trackedObject].o.m_saliency >0.0) { cout << "Tracking : " << trackedObject << " Salience : " << presentObjects[trackedObject].o.m_saliency << endl; } if (isControllingMotors && isFixationPointSafe(presentObjects[trackedObject].o.m_ego_position)) igaze->lookAtFixationPoint(presentObjects[trackedObject].o.m_ego_position); //Prepare the output img ImageOf<PixelRgb> &img=saliencyOutput.prepare(); img.copy(imageOut); saliencyOutput.write(); //Update the OPC values for(list<Entity*>::iterator it=entities.begin(); it !=entities.end(); it++) { if (presentObjects.find( (*it)->name()) != presentObjects.end()) { ((Object*)(*it))->m_saliency = presentObjects[(*it)->name()].o.m_saliency; } } opc->commit(); } presentObjectsLastStep = presentObjects; return true; }
bool PasarModule::updateModule() { opc->update(); entities = opc->EntitiesCache(); presentObjects.clear(); presentLastSpeed = presentCurrentSpeed; presentCurrentSpeed.clear(); for (list<Entity*>::iterator it = entities.begin(); it != entities.end(); it++) { if ((*it)->name() != "icub") { //!!! ONLY OBJECTS, RT_OBJECT and AGENTS ARE TRACKED !!! if ((*it)->isType(EFAA_OPC_ENTITY_RTOBJECT) || (*it)->isType(EFAA_OPC_ENTITY_AGENT) || (*it)->isType(EFAA_OPC_ENTITY_OBJECT)) { if ((*it)->isType(EFAA_OPC_ENTITY_RTOBJECT)) { RTObject * rto = dynamic_cast<RTObject*>(*it); presentObjects[(*it)->name()].o.fromBottle(rto->asBottle()); presentObjects[(*it)->name()].o.m_saliency = rto->m_saliency; } if ((*it)->isType(EFAA_OPC_ENTITY_OBJECT)) { Object * ob = dynamic_cast<Object*>(*it); presentObjects[(*it)->name()].o.fromBottle(ob->asBottle()); presentObjects[(*it)->name()].o.m_saliency = ob->m_saliency; } if ((*it)->isType(EFAA_OPC_ENTITY_AGENT)) { Agent *ag = dynamic_cast<Agent*>(*it); presentObjects[(*it)->name()].o.fromBottle(ag->asBottle()); presentObjects[(*it)->name()].o.m_saliency = ag->m_saliency; } } } } //if (presentObjects[ (*it)->name() ].o.m_saliency > 0) // cout<<" salience : " << (*it)->name() << " " << presentObjects[ (*it)->name() ].o.m_saliency << endl; if (presentObjectsLastStep.size() > 0) { //Compute top down saliency (concept based) saliencyTopDown(); if (isPointing) saliencyPointing(); if (isWaving) saliencyWaving(); //Normalize //saliencyNormalize(); //Inhinbition of return // if(trackedObject!= "") // presentObjects[trackedObject].o.m_saliency = max(0.0, presentObjects[trackedObject].o.m_saliency - pTopDownInhibitionReturn); //Leaky integrate saliencyLeakyIntegration(); //Get the most salient object and track it map< string, ObjectModel >::iterator mostSalientObject = presentObjects.begin(); for (map< string, ObjectModel >::iterator it = presentObjects.begin(); it != presentObjects.end(); it++) { // cout<<"Saliency ("<<it->second.o.name()<<") = "<<it->second.o.m_saliency<<endl; if (it->second.o.m_saliency > mostSalientObject->second.o.m_saliency) mostSalientObject = it; } trackedObject = mostSalientObject->first; if (presentObjects[trackedObject].o.m_saliency > 0.0) { cout << "Tracking : " << trackedObject << " Salience : " << presentObjects[trackedObject].o.m_saliency << endl; } //Update the OPC values for (list<Entity*>::iterator it = entities.begin(); it != entities.end(); it++) { if (presentObjects.find((*it)->name()) != presentObjects.end()) { (dynamic_cast<Object*>(*it))->m_saliency = presentObjects[(*it)->name()].o.m_saliency; } } opc->commit(); } presentObjectsLastStep = presentObjects; return true; }