VotingSpace.hpp
Go to the documentation of this file.
1 
18 #pragma once
19 //Pkg includes
20 //NOTE: Has to be included to enable the class to give a shared pointer of itself the an other function.
21 #include <boost/enable_shared_from_this.hpp>
22 #include <boost/thread/thread.hpp>
23 
24 //Local includes
25 #include "typedef.hpp"
26 #include "common_type/Point.hpp"
27 #include "VotedPose.hpp"
28 #include "common_type/Object.hpp"
29 #include "VotingBin.hpp"
30 
31 namespace ISM {
32 
33 //Computed VotedPoses (reference pose votes) are inserted into voxelgrid and each voxelgrid element is searched for promising combinations of votes.
34 class VotingSpace : public boost::enable_shared_from_this<VotingSpace>
35 {
36 
37 public:
38 
39  VotingSpace(double binSize, double maxProjectionAngleDeviation, int raterType = 0) :
40  enable_shared_from_this(),
41  binSize(binSize),
42  maxProjectionAngleDeviation(maxProjectionAngleDeviation),
43  mRaterType(raterType),
44  halfBinSize(binSize/(2.0)),
45  squaredRadius((3.0 / 4.0) * binSize * binSize),
46  offsetOfSphere((sqrt(3) * binSize / 2.0) - halfBinSize),
47  nThreads(boost::thread::hardware_concurrency()),
51  { }
52 
53  //Insertion into grid and its evaluation. This method is called for each sub-ISM at a time.
54  VotingResultPtrs fillAndEvalVotingSpace(VotedPosePtrs& votes, bool enabledSelfVoteCheck);
55  //Converts from cartesian to grid coordinates.
56  VotingBinPtr getBin(double x, double y, double z);
57  //Implements radius search during votingspace evaluation.
58  TypeToInnerMap collectVotesInSphere(PointPtr& centerPtr, bool& voteFromReferenceObjectExists);
59 
60  int discretizeToBins(double x);
61 
62  void calcResult(int i, VotingResultCalculatorPtr& calculator);
63 
64  //This is the actual grid, wrapped in this class.
66 
67  //Currently accepted deviations for scene recognition with the given grid.
68  double binSize;
70 
71  //Simple or APO-Rater enum.
72  const int mRaterType;
73 
74  //Some members for discretizeToBins.
75  const double halfBinSize;
76  static constexpr double epsilon = 1e-6;
77 
78  //Size of sphere for radius search.
79  // NOTE: const double radius = sqrt(3.0) * binSize / 2; Perform with diameter = bin diagonal around centerPtr = originForFitting.
80  const double squaredRadius;
81  //The sphere is larger than bin size.
82  const double offsetOfSphere;
83 
84  // per thread data/maybe extract this to a class
85  int nThreads;
86  std::vector<boost::shared_ptr<boost::thread>> threads;
87  std::vector<std::vector<VotingBinPtr>> votingBinsPerThread;
88  std::vector<std::vector<VotingResultPtr>> resultsPerThread;
89  int curThread;
90 };
91 }
VotingBinPtr getBin(double x, double y, double z)
Definition: VotingSpace.cpp:95
std::vector< std::vector< VotingResultPtr > > resultsPerThread
Definition: VotingSpace.hpp:88
boost::shared_ptr< VotingBin > VotingBinPtr
Definition: typedef.hpp:43
void calcResult(int i, VotingResultCalculatorPtr &calculator)
Definition: VotingSpace.cpp:83
VotingResultPtrs fillAndEvalVotingSpace(VotedPosePtrs &votes, bool enabledSelfVoteCheck)
Definition: VotingSpace.cpp:40
boost::shared_ptr< Point > PointPtr
Definition: Point.hpp:45
std::map< int, YIndexToZIndex > XIndexToYIndex
Definition: typedef.hpp:79
int discretizeToBins(double x)
const double squaredRadius
Definition: VotingSpace.hpp:80
const double halfBinSize
Definition: VotingSpace.hpp:75
std::vector< VotedPosePtr > VotedPosePtrs
Definition: typedef.hpp:59
const int mRaterType
Definition: VotingSpace.hpp:72
double maxProjectionAngleDeviation
Definition: VotingSpace.hpp:69
std::map< std::string, IdToVoteMap > TypeToInnerMap
Definition: typedef.hpp:71
VotingSpace(double binSize, double maxProjectionAngleDeviation, int raterType=0)
Definition: VotingSpace.hpp:39
std::vector< boost::shared_ptr< boost::thread > > threads
Definition: VotingSpace.hpp:86
const double offsetOfSphere
Definition: VotingSpace.hpp:82
boost::shared_ptr< VotingResultCalculator > VotingResultCalculatorPtr
std::vector< std::vector< VotingBinPtr > > votingBinsPerThread
Definition: VotingSpace.hpp:87
std::vector< VotingResultPtr > VotingResultPtrs
Definition: typedef.hpp:60
static constexpr double epsilon
Definition: VotingSpace.hpp:76
this namespace contains all generally usable classes.
XIndexToYIndex voteGrid
Definition: VotingSpace.hpp:65
TypeToInnerMap collectVotesInSphere(PointPtr &centerPtr, bool &voteFromReferenceObjectExists)


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:41