Recognizer.hpp
Go to the documentation of this file.
1 
18 #pragma once
19 
20 //Global includes
21 #include <string>
22 #include <boost/shared_ptr.hpp>
23 
24 //Local includes
26 #include "utility/TableHelper.hpp"
28 #include "VotedPose.hpp"
29 #include "typedef.hpp"
30 
31 namespace ISM {
35  class Recognizer {
36 
37  //Accessor to db, containing isms.
39  //Object constellation in which scene is to be recognized.
41 
42  //Parameters of voting space.
43  double bin_size;
45 
46  //All types of objects in sqlite table we got as input (for all scenes in this table)
47  std::set<std::string> objectTypes;
48 
49  //Votes for all objects in db, extracted from db and held in memory to calculate votesPoses.
51  //Used to get max expected weight per pattern.
53 
54  //All patterns in db, arranged according to their height.
56  //All voted poses, calculated during voting, arranged according to the pattern, in which voxel grid evaluation should take place.
58 
60 
61  //Simple or APO-Rater enum.
62  const int mRaterType;
63 
64  std::vector<RecognitionResultPtr> ismResults;
65  //Required to ensure that objects only vote once since, object voting and ism evaluation throughout the tree is decoupled.
66  std::map<ObjectPtr, std::vector<VotedPosePtr> > votingCache;
67 
69  //Copy of a voting space, filled by an ism, for its visualization.
71 
72  public:
82  Recognizer(const std::string& dbfilename, double bin_size, double maxProjectionAngleDeviation, bool enabledSelfVoteCheck, int raterType = 0);
83 
93  const std::vector<RecognitionResultPtr> recognizePattern(const ObjectSetPtr& objectSet,
94  const double filterThreshold = 0.0, const int resultsPerPattern = -1, const std::string targetPatternName = "");
95 
96  std::map<ObjectPtr, std::vector<VotedPosePtr> > getVotingCache()
97  {
98  return votingCache;
99  }
100 
101  //Interfaces to change settings of recognizer during runtime.
102 
104  {
105  this->voteSpecifiersPerObject = voteSpecifiersPerObject;
106  }
107 
108  void setObjectTypes(std::set<std::string> objectTypes)
109  {
110  this->objectTypes = objectTypes;
111  }
112 
114  {
115  this->patternDefinitions = patternDefinitions;
116  }
117 
118  //Create mapping that assigns all isms in the trees in db to their height in their tree.
120 
121  //Reset everything before looking for another scene
122 
123  void clearData()
124  {
125  objectTypes.clear();
126  assert(objectTypes.size() == 0);
127  voteSpecifiersPerObject.clear();
128  assert(voteSpecifiersPerObject.size() == 0);
129  patternDefinitions.clear();
130  assert(patternDefinitions.size() == 0);
131  }
132 
133  //Interfaces for ISM voting visualization
134 
136  {
137  this->patternForVotingSpaceViz = patternName;
138  }
139 
141  {
142  this->patternForVotingSpaceViz.clear();
143  return votingSpaceBuffer;
144  }
145 
146  private:
147 
148  //Two methods that make up iteration step of iterative scene recognition process.
149 
150  //Calculates voted poses (reference pose hypotheses), using resp. filling the voting cache, and assigns them to a pattern.
152  //For all ISMs at a given tree height: Inserts all voted poses into voxel grids and evaluates each element of the grid.
153  void fillAndEvalVotingSpaceAtTreeHeight(unsigned int treeHeight);
154 
156  int objectAlreadyInSet(const ObjectPtr& o);
157  PosePtr calculatePoseFromVote(const PosePtr& pose, const VoteSpecifierPtr& vote) const;
158 
159  //Create mapping from patternname String to patterns in db.
160  void getPatternDefinitions();
161 
162  //After having performed iterative scene recognition process, gather tree like scene recognition result from the single RecognitionResults from all sub-ISMs in the ISM tree. Uses getSubPatternsForResult.
163  static std::vector<RecognitionResultPtr> assembleIsmTrees(const std::vector<RecognitionResultPtr>& ismResults,
164  const double filterThreshold, const int resultsPerPattern, const std::string targetPatternName);
165 
166  //Search matching RecognitionResults in child ISMs in tree to build up tree structure of scene recognition result.
167  static std::vector<RecognitionResultPtr> getSubPatternsForResult(RecognitionResultPtr result,
168  std::map<std::string, std::vector<RecognitionResultPtr> > patternNameToResults);
169 
170  };
171  typedef boost::shared_ptr<Recognizer> RecognizerPtr;
172 
173 }
174 
175 
boost::shared_ptr< Recognizer > RecognizerPtr
Definition: Recognizer.hpp:171
PatternNameToVotedPoses patternToVotedPoses
Definition: Recognizer.hpp:57
void arrangePatternsAccordingToTreeHeight()
Definition: Recognizer.cpp:263
PatternNameToPatternMap patternDefinitions
Definition: Recognizer.hpp:52
static std::vector< RecognitionResultPtr > assembleIsmTrees(const std::vector< RecognitionResultPtr > &ismResults, const double filterThreshold, const int resultsPerPattern, const std::string targetPatternName)
Definition: Recognizer.cpp:355
const int mRaterType
Definition: Recognizer.hpp:62
ObjectSetPtr inputSet
Definition: Recognizer.hpp:40
void setPatternDefinitions(ISM::PatternNameToPatternMap patternDefinitions)
Definition: Recognizer.hpp:113
TableHelperPtr tableHelper
Definition: Recognizer.hpp:38
std::map< unsigned int, std::set< std::string > > TreeHeightToPatternName
Definition: typedef.hpp:66
bool enabledSelfVoteCheck
Definition: Recognizer.hpp:59
std::string patternName
static std::vector< RecognitionResultPtr > getSubPatternsForResult(RecognitionResultPtr result, std::map< std::string, std::vector< RecognitionResultPtr > > patternNameToResults)
Definition: Recognizer.cpp:419
PatternNameAndVotingSpaceTuple votingSpaceBuffer
Definition: Recognizer.hpp:70
void calculateVotedPosesForAllObjects()
Definition: Recognizer.cpp:69
boost::shared_ptr< TableHelper > TableHelperPtr
std::string patternForVotingSpaceViz
Definition: Recognizer.hpp:68
ObjectTypeToVoteMap voteSpecifiersPerObject
Definition: Recognizer.hpp:50
std::set< std::string > objectTypes
Definition: Recognizer.hpp:47
std::map< ObjectPtr, std::vector< VotedPosePtr > > getVotingCache()
Definition: Recognizer.hpp:96
std::map< ObjectPtr, std::vector< VotedPosePtr > > votingCache
Definition: Recognizer.hpp:66
PosePtr calculatePoseFromVote(const PosePtr &pose, const VoteSpecifierPtr &vote) const
Definition: Recognizer.cpp:243
boost::shared_ptr< VoteSpecifier > VoteSpecifierPtr
std::vector< RecognitionResultPtr > ismResults
Definition: Recognizer.hpp:64
void getPatternDefinitions()
Definition: Recognizer.cpp:248
boost::shared_ptr< ObjectSet > ObjectSetPtr
Definition: ObjectSet.hpp:53
int objectAlreadyInSet(const ObjectPtr &o)
Definition: Recognizer.cpp:232
boost::shared_ptr< RecognitionResult > RecognitionResultPtr
int resultAlreadyExisting(const RecognitionResultPtr &res)
Definition: Recognizer.cpp:220
std::map< std::string, VotedPosePtrs > PatternNameToVotedPoses
Definition: typedef.hpp:65
PatternNameAndVotingSpaceTuple getBufferedVotingSpace()
Definition: Recognizer.hpp:140
void setVoteSpecifiersPerObject(ISM::ObjectTypeToVoteMap voteSpecifiersPerObject)
Definition: Recognizer.hpp:103
boost::shared_ptr< Pose > PosePtr
Definition: Pose.hpp:79
void setVotingSpaceToBeBuffered(std::string patternName)
Definition: Recognizer.hpp:135
void fillAndEvalVotingSpaceAtTreeHeight(unsigned int treeHeight)
Definition: Recognizer.cpp:140
std::map< std::string, PatternPtr > PatternNameToPatternMap
Definition: TableHelper.hpp:37
double maxProjectionAngleDeviation
Definition: Recognizer.hpp:44
const std::vector< RecognitionResultPtr > recognizePattern(const ObjectSetPtr &objectSet, const double filterThreshold=0.0, const int resultsPerPattern=-1, const std::string targetPatternName="")
Definition: Recognizer.cpp:47
std::pair< std::string, VotingSpacePtr > PatternNameAndVotingSpaceTuple
Definition: typedef.hpp:63
this namespace contains all generally usable classes.
void setObjectTypes(std::set< std::string > objectTypes)
Definition: Recognizer.hpp:108
std::map< std::string, std::vector< VoteSpecifierPtr > > ObjectTypeToVoteMap
Definition: TableHelper.hpp:36
TreeHeightToPatternName patternPerTreeHeight
Definition: Recognizer.hpp:55
boost::shared_ptr< Object > ObjectPtr
Definition: Object.hpp:82
Recognizer(const std::string &dbfilename, double bin_size, double maxProjectionAngleDeviation, bool enabledSelfVoteCheck, int raterType=0)
Definition: Recognizer.cpp:37


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