TopologyAdapter.cpp
Go to the documentation of this file.
1 
19 
21 {
22 
23 double TopologyAdapter::CostFunction::calculateCost(ISM::TopologyPtr instance)
24 {
25  return instance->cost;
26 }
27 
28 TopologyAdapter::TopologyAdapter(std::vector<std::string> pObjectTypes, std::string pSceneId): mPSMTopologyIndex(0), mISMTopologyIndex(0), mSceneId(pSceneId)
29 {
30  // Generate all possible relations:
31  for (unsigned int i = 0; i < pObjectTypes.size() - 1; i++)
32  for (unsigned int j = i + 1; j < pObjectTypes.size(); j++)
33  mRelations.push_back(SceneModel::Relation(pObjectTypes[i], pObjectTypes[j]));
34 }
35 
37 { }
38 
40 {
41  ISM::TopologyPtr ismTopology(new ISM::Topology());
42 
43  ismTopology->index = mISMTopologyIndex;
45 
46  ismTopology->cost = pPsmTopology->getCost();
47 
48  // It is unknown whether an ism tree created for this topology would be valid.
49  // always assumed to be invalid.
50  ismTopology->isValid = false;
51 
52  ismTopology->identifier = pPsmTopology->mIdentifier;
53 
54  ismTopology->evaluationResult.falsePositives = pPsmTopology->getFalsePositives();
55  ismTopology->evaluationResult.falseNegatives = pPsmTopology->getFalseNegatives();
56  ismTopology->evaluationResult.averageRecognitionRuntime = pPsmTopology->getAverageRecognitionRuntime();
57 
58  // go over the relations and enumerate them according to their index in the list of all relations
59  for (unsigned int relationIndex = 0; relationIndex < mRelations.size(); relationIndex++)
60  {
61  std::string objectA = mRelations[relationIndex].getObjectTypeA();
62  std::string objectB = mRelations[relationIndex].getObjectTypeB();
63  for (boost::shared_ptr<SceneModel::Relation> relation: pPsmTopology->mRelations)
64  {
65  if (relation->containsObject(objectA) && relation->containsObject(objectB))
66  {
67  ISM::TrackPtr trackA(new ISM::Track(objectA));
68  ISM::TrackPtr trackB(new ISM::Track(objectB));
69  ISM::ObjectRelationPtr ismRelation(new ISM::ObjectRelation(trackA, trackB, mSceneId));
70  ismTopology->objectRelations[relationIndex] = ismRelation;
71  }
72  }
73  }
74 
75  return ismTopology;
76 }
77 
79 {
80  boost::shared_ptr<SceneModel::Topology> psmTopology(new SceneModel::Topology());
81 
82  // Most likely not used in PSM optimization
83  psmTopology->mUsedInOptimization = false;
84 
85  //mTree does not get assigned any value. Could make a tree with TopologyManager, but seems unneccessary here.
86 
87  psmTopology->setCost(pIsmTopology->cost);
88 
89  psmTopology->setEvaluationResult(pIsmTopology->evaluationResult.averageRecognitionRuntime,
90  pIsmTopology->evaluationResult.falsePositives,
91  pIsmTopology->evaluationResult.falseNegatives);
92 
93  // Note that this identifier may not be compatible with the ones assigned in PSM, for example in TopologyManager.
94  psmTopology->mIdentifier = pIsmTopology->identifier;
95 
96  for (std::pair<unsigned int, ISM::ObjectRelationPtr> relation: pIsmTopology->objectRelations)
97  {
98  std::string objectTypeA = relation.second->getObjectTypeA(); // Note that ISM distinguishes between an object's type and its id, whereas in PSM, there can only be one object of each type anyways.
99  std::string objectTypeB = relation.second->getObjectTypeB();
100  boost::shared_ptr<SceneModel::Relation> psmRelation(new SceneModel::Relation(objectTypeA, objectTypeB));
101  psmTopology->mRelations.push_back(psmRelation);
102  }
103 
104  return psmTopology;
105 }
106 
107 }
108 
boost::shared_ptr< SceneModel::Topology > ismToPsm(ISM::TopologyPtr pIsmTopology)
ISM::TopologyPtr psmToIsm(boost::shared_ptr< SceneModel::Topology > pPsmTopology)
std::vector< SceneModel::Relation > mRelations
TopologyAdapter(std::vector< std::string > pObjectTypes, std::string pSceneId)


asr_psm
Author(s): Braun Kai, Gehrung Joachim, Heizmann Heinrich, Meißner Pascal
autogenerated on Fri Nov 15 2019 04:00:08