AppearanceTermEvaluator.cpp
Go to the documentation of this file.
1 
19 
21 
23  : TermEvaluator()
24  {
25  // Initialize pointer.
27  }
28 
30  {
31  }
32 
33  void AppearanceTermEvaluator::load(boost::property_tree::ptree& pPt)
34  {
35  // Load mapped probability table.
36  mMappedTable->load(pPt.get_child("appearance"));
37  }
38 
40  {
41  // Here is no visualization required.
42  }
43 
44  double AppearanceTermEvaluator::calculateProbabilityForHypothesis(std::vector<ISM::Object> pEvidenceList, std::vector<unsigned int> pAssignments)
45  {
46  /**************************************************************************************************
47  * Build an entry of the conditional joint distribution P(A|h) bases on the given hypothesis
48  **************************************************************************************************/
49 
50  // The number of filled slots.
51  unsigned int numberOfFilledSlots = 0;
52 
53  double probability = 1.0;
54 
55  // If no part was assigned to the root node, we don't need to continue (because the model doesn't allow cases like this).
56  // In this case the probability stays zero, because that case it IMPOSSIBLE!
57  if(pAssignments[0] > 0)
58  {
59  // Evaluate all slots with associated objects. Multiply their probability to the hypothesis probability.
60  for(unsigned int slot = 0; slot < mMappedTable->getNumberOfRows(); slot++)
61  {
62  // Get the part assigned to the current slot.
63  unsigned int part = pAssignments[slot];
64 
65  // Ignore assignments of the zero-object, because later we anyway would have to marginalize it out.
66  // If a part with a larger index than zero is assigned, we associate the part with the probability table for the slot.
67  if(part > 0)
68  {
69  // Get the value from the probability table for the given slot and multiply it to the hypothesis probability.
70  // Subtract one from the part number, because the first element in the evidence vector is adressed by zero.
71  probability *= mMappedTable->getProbability(slot, pEvidenceList[part - 1].type);
72 
73  // Used to calculate the number of filled slots.
74  numberOfFilledSlots++;
75  }
76  }
77  } else {
78  // A hypothesis without an assigned root object is invalid and will therefore be scored with the impossible event.
79  probability = 0.0;
80  }
81 
82  // Return the probability for the given hypothesis.
83  return probability;
84  }
85 
86  void AppearanceTermEvaluator::visualize(std::vector<ISM::Object> pEvidenceList)
87  {
88  // No visualization to update.
89  }
90 
92  {
93  return mMappedTable->getNumberOfRows();
94  }
95 
96 }
double calculateProbabilityForHypothesis(std::vector< ISM::Object > pEvidenceList, std::vector< unsigned int > pAssignments)
void visualize(std::vector< ISM::Object > pEvidenceList)
void initializeVisualizer(boost::shared_ptr< Visualization::ProbabilisticPrimarySceneObjectVisualization > mSuperior)
boost::shared_ptr< MappedProbabilityTable > mMappedTable


asr_psm
Author(s): Braun Kai, Gehrung Joachim, Heizmann Heinrich, Meißner Pascal
autogenerated on Fri Nov 15 2019 03:57:54