inference/model/foreground/ocm/shape/GaussianKernel.cpp
Go to the documentation of this file.
1 
19 
21 
22 namespace PSMInference {
23 
24  GaussianKernel::GaussianKernel(unsigned int pDimension, boost::property_tree::ptree& pPt)
25  : mDimension(pDimension)
26  {
27  // Initialize pointers.
28  mMean.reset(new Eigen::VectorXd(pDimension));
29  mCovariance.reset(new Eigen::MatrixXd(pDimension, pDimension));
30 
31  mPositionMean.reset(new Eigen::Vector3d());
32  mPositionCovariance.reset(new Eigen::Matrix3d());
33 
34  // Load weight, mean and covariance.
35  load(pPt);
36  }
37 
39  {
40 
41  }
42 
43  void GaussianKernel::load(boost::property_tree::ptree& pPt)
44  {
45  // Load the weight.
46  mWeight = pPt.get<double>("<xmlattr>.weight");
47 
48  // Load the mean vector.
49  std::string meanAsString = pPt.get<std::string>("<xmlattr>.mean");
51 
52  // Load the covariance matrix.
53  std::string covarianceAsString = pPt.get<std::string>("<xmlattr>.covariance");
55 
56  // Extract the parts of mean and covariance relevant for the position.
57  *mPositionMean = mMean->block<3,1>(0,0);
58  *mPositionCovariance = mCovariance->block<3,3>(0,0);
59  }
60 
62  {
63  mVisualizer->appendKernel(mPositionMean, mPositionCovariance);
64  }
65 
67  {
68  mVisualizer->setDetectionCertainty(evaluate(pEvidence));
69  }
70 
71  double GaussianKernel::evaluate(Eigen::VectorXd pEvidence)
72  {
73  return mWeight * exp(-sqrt((double) ((pEvidence - *mMean).transpose() * mCovariance->inverse() * (pEvidence - *mMean))));
74  }
75 
77  {
78  return mWeight;
79  }
80 
81 }
82 
83 }
void visualize(boost::shared_ptr< Visualization::ProbabilisticSecondarySceneObjectVisualization > mVisualizer, Eigen::VectorXd pEvidence)
static void convertStringToVector(std::string &str, std::vector< double > &vec)
void initializeVisualizer(boost::shared_ptr< Visualization::ProbabilisticSecondarySceneObjectVisualization > mVisualizer)
static void convertStringToMatrix(unsigned int size, std::string &str, boost::shared_ptr< Eigen::MatrixXd > &mat)


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