PowerSetBackgroundInferenceAlgorithm.cpp
Go to the documentation of this file.
1 
19 
21 
24  , mProbability(0.0)
25  {
26  }
27 
29  {
30  }
31 
32  void PowerSetBackgroundInferenceAlgorithm::doInference(std::vector<ISM::Object> pEvidenceList, std::ofstream& pRuntimeLogger)
33  {
34  /**************************************************************************************
35  * What we do here:
36  *
37  * This are basically the same calculations like in the foreground scene. We calculate
38  * the probability of the scene based on the scene objects, exactly like in the
39  * foreground scene.
40  *
41  * However, the probability of the scene objects are calculated under an
42  * equal distribution. We assume that there's a scene object for every detected object.
43  *
44  * The objects are combined in a power set approach. First the power set of all object
45  * combinations is calculated. For every combination the scene objects are evaluated.
46  * The results of each combination (= subset in power set) are summarized to form
47  * the scene probability.
48  ***************************************************************************************/
49 
50  // Reset the scene probability. We MARGINALZE here, so we set it to ZERO.
51  mProbability = 0.0;
52 
53  // The number of all hypotheses.
54  unsigned int numberOfHypotheses = 0;
55 
56  // The number of scene objects equals the number of evidences.
57  unsigned int numberOfSceneObjects = pEvidenceList.size();
58 
59  // We iterate over the power set over the scene objects.
60  for(unsigned int i = 1; i < ((unsigned int) 1 << numberOfSceneObjects); ++i)
61  {
62  // String containing the subset for debugging.
63  std::string subset;
64 
65  // The score for this subset. We MULTIPLY the scene object scores, to we initialize it with ONE.
66  double hypothesisProbability = 1.0;
67 
68  // The number of elements in this subset.
69  unsigned int numberOfElementsInSubset = 0;
70 
71  // Here we determine the number of elements in the subset of the power set.
72  for(unsigned int j = 0; j < numberOfSceneObjects; ++j)
73  {
74  // Is element in subset?
75  if((1 << j) & i)
76  numberOfElementsInSubset++;
77  }
78 
79  // Here we determine and evaluate the subset of the power set.
80  for(unsigned int j = 0; j < numberOfSceneObjects; ++j)
81  {
82  // Is element in subset?
83  if((1 << j) & i)
84  {
85  // Add the current subset number to the debug message string.
86  subset += "(" + boost::lexical_cast<std::string>(j) + ") ";
87 
88  // Update score based on the score of an equal distributed background object and an appropriate prior.
89  // The prior is a binary uniform distribution over the cases 'object there' and 'object not there'.
90  hypothesisProbability *= calculateProbabilityOfBackgroundSceneObject(numberOfElementsInSubset, numberOfElementsInSubset) * 0.5;
91 
92  ROS_INFO_STREAM(" > Multiplying with subset score: '" << calculateProbabilityOfBackgroundSceneObject(numberOfElementsInSubset, numberOfElementsInSubset) << "' with priori '0.5'.");
93  }
94  }
95 
96  // Debug message.
97  ROS_INFO_STREAM("Score for scene object subset '" << subset << "' is '" << hypothesisProbability << "'.");
98 
99  // Add hypothesis to scene probability. We score the empty subset with zero.
100  if(i > 0)
101  mProbability += hypothesisProbability;
102 
103  // +1 for the number of hypotheses.
104  numberOfHypotheses++;
105  }
106 
107  // Apply normalization term by dividing by the number of all hypotheses.
108  if(numberOfHypotheses > 0)
109  mProbability /= numberOfHypotheses;
110  }
111 
113  {
114  return mProbability;
115  }
116 
117 }
void doInference(std::vector< ISM::Object > pEvidenceList, std::ofstream &pRuntimeLogger)
#define ROS_INFO_STREAM(args)
double calculateProbabilityOfBackgroundSceneObject(unsigned int pNumberOfEvidence, unsigned int pNumberOfSlots)


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