APORater.hpp
Go to the documentation of this file.
1 
18 #pragma once
19 
20 #include "BaseRater.hpp"
21 
22 namespace ISM {
26 class APORater : public BaseRater
27 {
28 
29 public:
30  APORater(double bin_size, double maxAngleDeviation) : BaseRater(bin_size, maxAngleDeviation)
31  {
32  //We calculated a factor for sigma so that exp() is 0.5 at sqrt(3)*/(bin_size*2).
33  // https://www.wolframalpha.com/input/?i=e%5E(((-(sqrt(3)%2F2*s)%5E2))%2F(2*(sigma)%5E2))%3D0.5
34  squaredSigma = -0.735534 * bin_size * -0.735534 * bin_size;
35  }
36 
37  //Methods are inlined for performance reasons.
38 
39  // No input checks at all since that method must run fast.
40  virtual double rateAtBackProjectionLevel(VotedPosePtr& votedPose, RatingDataPtr data){
41 
42  /* Note: rate position with density function of a normal distribution without the scaling factor,
43  so that the score is in [0,1] */
44  double positionScore;
45  positionScore = exp(-0.5 * (data->backProjectionSquaredDistance / squaredSigma));
46 
47  /* Note: rate orientation with a customized cosinus function, which resemble the density function above
48  and the score is in [0,1]*/
49  double orientationScore;
50 
51  //We doubled the limit for cos() so that this function is 0.5 at angleDeviation == maxAngleDeviation.
52  // doubled area of angles with values > 0
53  orientationScore = (data->angleDeviation < 2 * maxAngleDeviation) ? 0.5 + 0.5 * cos((M_PI * data->angleDeviation) / ( 2 * maxAngleDeviation)) : 0.0;
54 
55  double poseScore = positionScore * orientationScore;
56 
57  double totalScore = votedPose->weight - 1.0 + poseScore;
58 
59  /*Option to rate appearance in the furture*/
60  //double appearanceScore = 1.0;
61  //totalScore *= appearanceScore;
62 
63  return totalScore;
64 
65  }
66 
67  virtual void printRatingAtBackProjectionLevel(VotedPosePtr& votedPose, PosePtr& refPose, RatingDataPtr data){
68 
69  if (data == nullptr)
70  data = RatingDataPtr(new RatingData());
71 
72  if (!this->isVoteSupportingReference(votedPose, refPose, data))
73  {
74  std::cout << "Doesn't support reference -> APORater score=0.0" << std::endl;
75  return;
76  }
77 
78  /* Note: rate position with density function of a normal distribution without the scaling factor,
79  so that the score is in [0,1] */
80  double positionScore;
81  positionScore = exp(-0.5 * (data->backProjectionSquaredDistance / squaredSigma));
82 
83  /* Note: rate orientation with a customized cosinus function, which resemble the density function above
84  and the score is in [0,1]*/
85  double orientationScore;
86 
87  //We doubled the limit for cos() so that this function is 0.5 at angleDeviation == maxAngleDeviation.
88  // doubled area of angles with values > 0
89  orientationScore = (data->angleDeviation < 2 * maxAngleDeviation) ? 0.5 + 0.5 * cos((M_PI * data->angleDeviation) / ( 2 * maxAngleDeviation)) : 0.0;
90 
91  double poseScore = positionScore * orientationScore;
92 
93  double totalScore;
94  if (votedPose->source->type.find("_sub") != std::string::npos) //sub-ism
95  {
96  totalScore = votedPose->weight - 1.0 + poseScore;
97  }
98  else //object
99  {
100  totalScore = poseScore;
101  /*Option to rate appearance in the furture*/
102  //double appearanceScore = 1.0;
103  //totalScore = appearanceScore * poseScore;
104  }
105 
106  std::cout << "APORater score=" << totalScore << " with"
107  << "\n\tPositionScore=" << positionScore << " with squaredDistance=" << data->backProjectionSquaredDistance << " maxSquaredDistancepDeviation=" << (squaredSigma * 9) << " squaredSigma=" << squaredSigma
108  << "\n\tOrientationScore=" << orientationScore << " with angleDeviation=" << data->angleDeviation << " maxAngleDeviation=" << maxAngleDeviation
109  << "\nNormalized score=" << totalScore/votedPose->weightDenominator << " with denominator: " << votedPose->weightDenominator << std::endl;
110 
111  return;
112 
113  }
114 
115 private:
116  double squaredSigma;
117 };
118 }
const double maxAngleDeviation
Definition: BaseRater.hpp:85
bool isVoteSupportingReference(VotedPosePtr &votedPose, PosePtr &refPose, RatingDataPtr data)
Definition: BaseRater.hpp:46
boost::shared_ptr< RatingData > RatingDataPtr
Definition: RatingData.hpp:38
virtual void printRatingAtBackProjectionLevel(VotedPosePtr &votedPose, PosePtr &refPose, RatingDataPtr data)
Definition: APORater.hpp:67
boost::shared_ptr< VotedPose > VotedPosePtr
Definition: typedef.hpp:31
virtual double rateAtBackProjectionLevel(VotedPosePtr &votedPose, RatingDataPtr data)
Definition: APORater.hpp:40
double squaredSigma
Definition: APORater.hpp:116
boost::shared_ptr< Pose > PosePtr
Definition: Pose.hpp:79
this namespace contains all generally usable classes.
APORater(double bin_size, double maxAngleDeviation)
Definition: APORater.hpp:30


asr_lib_ism
Author(s): Hanselmann Fabian, Heller Florian, Heizmann Heinrich, Kübler Marcel, Mehlhaus Jonas, Meißner Pascal, Qattan Mohamad, Reckling Reno, Stroh Daniel
autogenerated on Wed Jan 8 2020 04:02:40